I found this problem when running 'make check' with the latest coreutils, and pushed the following patch.
--- ChangeLog | 7 +++++++ tests/test-getlogin.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7e0129e..cca6c07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-11-09 Paul Eggert <[email protected]> + + getlogin-tests: allow errno == ENOENT + * tests/test-getlogin.c (main): Skip tests if getlogin fails + with errno == ENOENT. This happened to me on Ubuntu 12.04.1 x86, + when running a test in an Emacs shell buffer. + 2012-11-08 Jim Meyering <[email protected]> tests/nap.h: avoid warning about unused variable diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 449ceaa..d86fec2 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -39,6 +39,13 @@ main (void) buf = getlogin (); if (buf == NULL) { + if (errno == ENOENT) + { + /* This can happen on GNU/Linux. */ + fprintf (stderr, "Skipping test: no entry in utmp file.\n"); + return 77; + } + /* getlogin() fails when stdin is not connected to a tty. */ ASSERT (errno == ENOTTY || errno == EINVAL /* seen on Linux/SPARC */ -- 1.7.11.7
