summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2012-11-09 11:55:25 +0000
committerPádraig Brady <P@draigBrady.com>2012-11-09 11:58:55 +0000
commitbfe5b0dfd062fb9ffbc61b27a0d750c41abc1a8e (patch)
tree892042718e0612b2cee118273980f544078d4a9f /tests
parent4f81aa5778dc88b99d21ad8d04a4bc9401366311 (diff)
downloadgnulib-bfe5b0dfd062fb9ffbc61b27a0d750c41abc1a8e.tar.gz
getlogin_r-tests: allow errno == ENXIO or ENOENT
* tests/test-getlogin.c (main): Skip tests if getlogin fails with errno == ENXIO (No controlling tty). * tests/test-getlogin_r.c (main): Skip tests if getlogin_r fails with errno == ENOENT. This was reported to happen in various situations on GNU/Linux.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-getlogin.c1
-rw-r--r--tests/test-getlogin_r.c8
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c
index d86fec2758..f7903ae1c9 100644
--- a/tests/test-getlogin.c
+++ b/tests/test-getlogin.c
@@ -49,6 +49,7 @@ main (void)
/* 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));
diff --git a/tests/test-getlogin_r.c b/tests/test-getlogin_r.c
index 043aafbb3d..45b6e7a476 100644
--- a/tests/test-getlogin_r.c
+++ b/tests/test-getlogin_r.c
@@ -40,9 +40,17 @@ main (void)
err = getlogin_r (buf, sizeof (buf));
if (err != 0)
{
+ if (errno == ENOENT)
+ {
+ /* This can happen on GNU/Linux. */
+ fprintf (stderr, "Skipping test: no entry in utmp file.\n");
+ return 77;
+ }
+
/* getlogin_r() fails when stdin is not connected to a tty. */
ASSERT (err == ENOTTY
|| errno == EINVAL /* seen on Linux/SPARC */
+ || errno == ENXIO
);
#if !defined __hpux /* On HP-UX 11.11 it fails anyway. */
ASSERT (! isatty (0));