From: Bruno Haible Date: Tue, 12 Jan 2010 08:51:24 +0000 (+0100) Subject: getlogin, getlogin_r: Avoid test failure. X-Git-Tag: v0.1~4756 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=7521ea075f22293b395517a5d2f4ea213b63d4a9;p=gnulib.git getlogin, getlogin_r: Avoid test failure. --- diff --git a/ChangeLog b/ChangeLog index 143056e30..fac2f33ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-01-12 Simon Josefsson + Bruno Haible + + getlogin, getlogin_r: Avoid test failure. + * tests/test-getlogin.c: Include . + (main): Skip the test when the function fails because stdin is not a + tty. + * tests/test-getlogin_r.c: Include . + (main): Skip the test when the function fails because stdin is not a + tty. + 2010-01-11 Eric Blake tests: avoid more large file warnings diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 65892890d..136510832 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -23,6 +23,7 @@ #include "signature.h" SIGNATURE_CHECK (getlogin, char *, (void)); +#include #include #include @@ -35,7 +36,13 @@ main (void) /* Test value. */ buf = getlogin (); - ASSERT (buf != NULL); + if (buf == NULL) + { + /* getlogin() fails when stdin is not connected to a tty. */ + ASSERT (! isatty (0)); + fprintf (stderr, "Skipping test: stdin is not a tty.\n"); + return 77; + } /* Compare against the value from the environment. */ #if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) diff --git a/tests/test-getlogin_r.c b/tests/test-getlogin_r.c index f566e038c..68c681232 100644 --- a/tests/test-getlogin_r.c +++ b/tests/test-getlogin_r.c @@ -24,6 +24,7 @@ SIGNATURE_CHECK (getlogin_r, int, (char *, size_t)); #include +#include #include #include @@ -35,7 +36,13 @@ main (void) /* Test with a large enough buffer. */ char buf[1024]; - ASSERT (getlogin_r (buf, sizeof (buf)) == 0); + if (getlogin_r (buf, sizeof (buf)) != 0) + { + /* getlogin_r() fails when stdin is not connected to a tty. */ + ASSERT (! isatty (0)); + fprintf (stderr, "Skipping test: stdin is not a tty.\n"); + return 77; + } /* Compare against the value from the environment. */ #if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)