From: Paul Eggert Date: Fri, 9 Nov 2012 09:03:33 +0000 (-0800) Subject: getlogin-tests: allow errno == ENOENT X-Git-Tag: v0.1~373 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=4f81aa5778dc88b99d21ad8d04a4bc9401366311;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 7e0129ecfa..cca6c07136 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-11-09 Paul Eggert + + 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 tests/nap.h: avoid warning about unused variable diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 449ceaa26c..d86fec2758 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 */