Subject: Re: bug#14768: portage build of sys-apps/coreutils-8.20 fails tests

From: Paul Eggert <[email-masked]>
Date: Tue, 02 Jul 2013 10:40:07 -0700

Thanks for the bug report.
Does the following patch work, when applied to gnulib-tests/test-getlogin.c?
If so, the bug is already fixed upstream.
If not, please run test-getlogin under GDB and see why it's failing.

--- old/test-getlogin.c	2012-10-23 07:17:25.000000000 -0700
+++ new/test-getlogin.c	2013-04-24 14:38:30.257537968 -0700
@@ -1,5 +1,5 @@
 /* Test of getting user name.
-   Copyright (C) 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -39,9 +39,17 @@
   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 */
+              || errno == ENXIO
              );
 #if !defined __hpux /* On HP-UX 11.11 it fails anyway.  */
       ASSERT (! isatty (0));