diff options
author | Bruno Haible <bruno@clisp.org> | 2010-01-12 09:51:24 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2010-01-12 09:51:24 +0100 |
commit | 7521ea075f22293b395517a5d2f4ea213b63d4a9 (patch) | |
tree | 019ded3660674b32e769d520761afa916cd19a79 /tests | |
parent | 0a68a3d852c46f4d23bb0239c0e9f3398d71823f (diff) | |
download | gnulib-7521ea075f22293b395517a5d2f4ea213b63d4a9.tar.gz |
getlogin, getlogin_r: Avoid test failure.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-getlogin.c | 9 | ||||
-rw-r--r-- | tests/test-getlogin_r.c | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 65892890da..136510832a 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -23,6 +23,7 @@ #include "signature.h" SIGNATURE_CHECK (getlogin, char *, (void)); +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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 f566e038c8..68c681232b 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 <errno.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -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__) |