]> Savannah Git Hosting - gnulib.git/commitdiff
getlogin_r-tests: fix various issues in recent change
authorPádraig Brady <P@draigBrady.com>
Thu, 22 May 2014 16:09:49 +0000 (17:09 +0100)
committerPádraig Brady <P@draigBrady.com>
Thu, 22 May 2014 16:24:58 +0000 (17:24 +0100)
* tests/test-getlogin_r.c: Include required headers that were
missed in recent commit eec20b4e.
Also consistently check the errno rather than the return value from
getlogin_r as POSIX only specifies that non zero is returned on error.
* modules/getlogin_r-tests (configure.ac): Add the check for ttyname().

ChangeLog
modules/getlogin_r-tests
tests/test-getlogin_r.c

index 35ddc055ddce0288dda5e6d62356d5f80d4917d7..aa3435059d7011691a7e1306d689248891dd695e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-05-22  Pádraig Brady  <P@draigBrady.com>
+
+       getlogin_r-tests: fix various issues in recent change
+       * tests/test-getlogin_r.c: Include required headers that were
+       missed in recent commit eec20b4e.
+       Also consistently check the errno rather than the return value from
+       getlogin_r as POSIX only specifies that non zero is returned on error.
+       * modules/getlogin_r-tests (configure.ac): Add the check for ttyname().
+
 2014-05-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        fchdir: port 'open' and 'close' redefinitions to AIX 7.1
index 22dfba5439dc2ed0044a9abcadbe715ec5003471..eda7b45324d7c1f68213b1b45cbf2c7c70aee428 100644 (file)
@@ -6,6 +6,7 @@ tests/macros.h
 Depends-on:
 
 configure.ac:
+AC_CHECK_FUNCS_ONCE([ttyname])
 
 Makefile.am:
 TESTS += test-getlogin_r
index fb3f9bffb1b590be3169b454d4d2150dded880b5..5c7078df8ed84ce916c105d10818736edc3d8c2d 100644 (file)
@@ -27,6 +27,11 @@ SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #include "macros.h"
 
@@ -48,7 +53,7 @@ main (void)
         }
 
       /* getlogin_r() fails when stdin is not connected to a tty.  */
-      ASSERT (err == ENOTTY
+      ASSERT (errno == ENOTTY
               || errno == EINVAL /* seen on Linux/SPARC */
               || errno == ENXIO
              );