X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-getlogin.c;h=449ceaa26cbcf3d4d6a92ab22102f5752f518e48;hb=80c3530fa6f0b67feb8e3a01c6ae0f3074d8129d;hp=65892890da98c0373e9d82320d0be9fbc6a5c28c;hpb=39331312abd1f8eb8578ef30f7cb5d3ea8e0f4fd;p=gnulib.git diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 65892890d..449ceaa26 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -1,5 +1,5 @@ /* Test of getting user name. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include "signature.h" SIGNATURE_CHECK (getlogin, char *, (void)); +#include +#include #include #include @@ -35,7 +37,18 @@ main (void) /* Test value. */ buf = getlogin (); - ASSERT (buf != NULL); + if (buf == NULL) + { + /* getlogin() fails when stdin is not connected to a tty. */ + ASSERT (errno == ENOTTY + || errno == EINVAL /* seen on Linux/SPARC */ + ); +#if !defined __hpux /* On HP-UX 11.11 it fails anyway. */ + ASSERT (! isatty (0)); +#endif + 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__)