[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
getlogin tests, getlogin_r tests: Avoid failure on Solaris OpenIndiana
From: |
Bruno Haible |
Subject: |
getlogin tests, getlogin_r tests: Avoid failure on Solaris OpenIndiana |
Date: |
Wed, 30 Dec 2020 15:02:07 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) |
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 <bruno@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. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- getlogin tests, getlogin_r tests: Avoid failure on Solaris OpenIndiana,
Bruno Haible <=