getlogin-tests: allow errno == ENOENT
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 9 Nov 2012 09:03:33 +0000 (01:03 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 9 Nov 2012 09:04:08 +0000 (01:04 -0800)
* 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.

ChangeLog
tests/test-getlogin.c

index 7e0129e..cca6c07 100644 (file)
--- 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
index 449ceaa..d86fec2 100644 (file)
@@ -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 */