changeset 17667:c25d6a669147

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().
author Pádraig Brady <P@draigBrady.com>
date Thu, 22 May 2014 17:09:49 +0100
parents 4ffedeebd641
children 4759a0035187
files ChangeLog modules/getlogin_r-tests tests/test-getlogin_r.c
diffstat 3 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu May 22 00:05:01 2014 -0700
+++ b/ChangeLog	Thu May 22 17:09:49 2014 +0100
@@ -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
--- a/modules/getlogin_r-tests	Thu May 22 00:05:01 2014 -0700
+++ b/modules/getlogin_r-tests	Thu May 22 17:09:49 2014 +0100
@@ -6,6 +6,7 @@
 Depends-on:
 
 configure.ac:
+AC_CHECK_FUNCS_ONCE([ttyname])
 
 Makefile.am:
 TESTS += test-getlogin_r
--- a/tests/test-getlogin_r.c	Thu May 22 00:05:01 2014 -0700
+++ b/tests/test-getlogin_r.c	Thu May 22 17:09:49 2014 +0100
@@ -27,6 +27,11 @@
 #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 @@
         }
 
       /* 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
              );