[commit: packages/unix] master, safe710fixes, safe710fixes-again, safefixes710again: Enable test for getLoginName (cad1ef2)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 15:49:33 UTC 2015


Repository : ssh://git@git.haskell.org/unix

On branches: master,safe710fixes,safe710fixes-again,safefixes710again
Link       : http://ghc.haskell.org/trac/ghc/changeset/cad1ef27bb0a51bc68ebadb1297de1ae05bee9db/unix

>---------------------------------------------------------------

commit cad1ef27bb0a51bc68ebadb1297de1ae05bee9db
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Thu Jun 26 23:23:15 2014 +0200

    Enable test for getLoginName
    
    Fixes #1487.
    
    Make use of no_stdin test option, introduced explictly for this purpose
    in fa52a8c9d8eae5e3fc4c0cf0e5672875e161e05c


>---------------------------------------------------------------

cad1ef27bb0a51bc68ebadb1297de1ae05bee9db
 tests/all.T          | 14 +++++++++++++-
 tests/user001.hs     |  4 ++--
 tests/user001.stdout |  2 ++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/tests/all.T b/tests/all.T
index 6b9fa15..b6bd433 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -11,7 +11,19 @@ test('forkprocess01', [ only_compiler_types(['ghc']),
 # user001 may fail due to this bug in glibc:
 #   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466647
 #
-test('user001', normal, compile_and_run, ['-package unix'])
+# user001 may also fail on GNU/Linux when using a terminal emulator that doesn't
+# write login records to /var/run/utmp. Running:
+#   $ logname
+# should print your login name. If it doesn't, the getLoginName test in user001
+# will fail, and that's why you are here. Try xterm.
+#
+# Ticket #1487. The glibc implementation of getlogin, which is called by
+# getLoginName, requires that a terminal is connected to filedescriptor 0.
+# See: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/getlogin.c
+# Therefore, we use the no_stdin option, and have to omit the 'ghci' way,
+# because it relies on redirecting stdin from file.
+#
+test('user001', [no_stdin, omit_ways(['ghci'])], compile_and_run, ['-package unix'])
 test('resourceLimit', normal, compile_and_run, ['-package unix'])
 
 x86FreeBsdFail = when(platform('i386-unknown-freebsd'), expect_fail)
diff --git a/tests/user001.hs b/tests/user001.hs
index ebbb464..f4c44fc 100644
--- a/tests/user001.hs
+++ b/tests/user001.hs
@@ -17,11 +17,11 @@ main = do p "getRealUserID"        $ getRealUserID
           p "getEffectiveUserID"   $ getEffectiveUserID
           p "getEffectiveGroupID"  $ getEffectiveGroupID
           p "getGroups"            $ getGroups
-          -- p "getLoginName"         $ getLoginName
+          p "getLoginName"         $ getLoginName
           p "getEffectiveUserName" $ getEffectiveUserName
           p "getGroupEntryForID"   $ getRealGroupID >>= getGroupEntryForID
           p "getGroupEntryForName" $ getRealGroupID >>= getGroupEntryForID >>= getGroupEntryForName . groupName
           p "getAllGroupEntries"   $ getAllGroupEntries
           p "getUserEntryForID"    $ getRealUserID >>= getUserEntryForID
-          -- p "getUserEntryForName"  $ getLoginName >>= getUserEntryForName
+          p "getUserEntryForName"  $ getLoginName >>= getUserEntryForName
           p "getAllUserEntries"    $ getAllUserEntries
diff --git a/tests/user001.stdout b/tests/user001.stdout
index e2e03df..48c0cfd 100644
--- a/tests/user001.stdout
+++ b/tests/user001.stdout
@@ -3,9 +3,11 @@ getRealGroupID: OK
 getEffectiveUserID: OK
 getEffectiveGroupID: OK
 getGroups: OK
+getLoginName: OK
 getEffectiveUserName: OK
 getGroupEntryForID: OK
 getGroupEntryForName: OK
 getAllGroupEntries: OK
 getUserEntryForID: OK
+getUserEntryForName: OK
 getAllUserEntries: OK



More information about the ghc-commits mailing list