On Solaris 11 OpenIndiana, I'm seeing two test failures: FAIL: test-getlogin ===================
../../gltests/test-getlogin.c:34: assertion 'buf || err' failed FAIL test-getlogin (exit status: 262) FAIL: test-getlogin_r ===================== ../../gltests/test-getlogin.h:51: assertion '! isatty (0)' failed FAIL test-getlogin_r (exit status: 262) In this situation, getlogin() returns NULL with errno not set. This is valid according to POSIX. <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html> And getlogin_r() returns EINVAL — a return value that is otherwise not seen on Solaris. This patch avoids the test failures. 2020-12-30 Bruno Haible <br...@clisp.org> getlogin tests, getlogin_r tests: Avoid failure on Solaris OpenIndiana. * tests/test-getlogin.c (main): Don't fail if getlogin() returns NULL with no errno. * tests/test-getlogin_r.c (main): Don't fail if getlogin_r() returns EINVAL. diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index a3048f2..f0d168b 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -31,7 +31,14 @@ main (void) /* Test value. */ char *buf = getlogin (); int err = buf ? 0 : errno; - ASSERT (buf || err); +#if defined __sun + if (buf == NULL && err == 0) + { + /* This can happen on Solaris 11 OpenIndiana in the MATE desktop. */ + fprintf (stderr, "Skipping test: no entry in /var/adm/utmpx.\n"); + exit (77); + } +#endif test_getlogin_result (buf, err); return 0; diff --git a/tests/test-getlogin_r.c b/tests/test-getlogin_r.c index 69d0bae..88c41fe 100644 --- a/tests/test-getlogin_r.c +++ b/tests/test-getlogin_r.c @@ -32,6 +32,14 @@ main (void) /* Test with a large enough buffer. */ char buf[1024]; int err = getlogin_r (buf, sizeof buf); +#if defined __sun + if (err == EINVAL) + { + /* This can happen on Solaris 11 OpenIndiana in the MATE desktop. */ + fprintf (stderr, "Skipping test: no entry in /var/adm/utmpx.\n"); + exit (77); + } +#endif test_getlogin_result (buf, err); /* Test with a small buffer. */