changeset 17156:75c813b2d840

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.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 09 Nov 2012 01:03:33 -0800
parents 5964b27e0bf3
children bb02af8a620b
files ChangeLog tests/test-getlogin.c
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-11-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+	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  <jim@meyering.net>
 
 	tests/nap.h: avoid warning about unused variable
--- a/tests/test-getlogin.c
+++ b/tests/test-getlogin.c
@@ -39,6 +39,13 @@
   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 */