From 7521ea075f22293b395517a5d2f4ea213b63d4a9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 12 Jan 2010 09:51:24 +0100 Subject: getlogin, getlogin_r: Avoid test failure. --- tests/test-getlogin_r.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/test-getlogin_r.c') 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 +#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__) -- cgit v1.2.1