X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-getlogin_r.c;h=ed103c9fc700af310db8e2e3e2e661ddcbb71d68;hb=95886da0b417a14882bb47bf4765f7af450d51da;hp=978efa4362edc83026a03748d041b193adc8c4b5;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/tests/test-getlogin_r.c b/tests/test-getlogin_r.c index 978efa436..ed103c9fc 100644 --- a/tests/test-getlogin_r.c +++ b/tests/test-getlogin_r.c @@ -1,5 +1,5 @@ /* Test of getting user name. - Copyright (C) 2010-2011 Free Software Foundation, Inc. + Copyright (C) 2010-2014 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 @@ -40,8 +40,18 @@ main (void) err = getlogin_r (buf, sizeof (buf)); if (err != 0) { + if (errno == ENOENT) + { + /* This can happen on GNU/Linux. */ + fprintf (stderr, "Skipping test: no entry in utmp file.\n"); + return 77; + } + /* getlogin_r() fails when stdin is not connected to a tty. */ - ASSERT (err == ENOTTY); + ASSERT (err == ENOTTY + || errno == EINVAL /* seen on Linux/SPARC */ + || errno == ENXIO + ); #if !defined __hpux /* On HP-UX 11.11 it fails anyway. */ ASSERT (! isatty (0)); #endif @@ -78,7 +88,13 @@ main (void) size_t i; for (i = 0; i <= n; i++) - ASSERT (getlogin_r (smallbuf, i) == ERANGE); + { + err = getlogin_r (smallbuf, i); + if (i == 0) + ASSERT (err == ERANGE || err == EINVAL); + else + ASSERT (err == ERANGE); + } } /* Test with a huge buffer. */