summaryrefslogtreecommitdiff
path: root/tests/test-getlogin_r.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2010-01-12 09:51:24 +0100
committerBruno Haible <bruno@clisp.org>2010-01-12 09:51:24 +0100
commit7521ea075f22293b395517a5d2f4ea213b63d4a9 (patch)
tree019ded3660674b32e769d520761afa916cd19a79 /tests/test-getlogin_r.c
parent0a68a3d852c46f4d23bb0239c0e9f3398d71823f (diff)
downloadgnulib-7521ea075f22293b395517a5d2f4ea213b63d4a9.tar.gz
getlogin, getlogin_r: Avoid test failure.
Diffstat (limited to 'tests/test-getlogin_r.c')
-rw-r--r--tests/test-getlogin_r.c9
1 files changed, 8 insertions, 1 deletions
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__)