From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: poll tests: Avoid test failure on BSD and Solaris systems
Date: Thu, 31 Dec 2020 23:39:09 +0100 [thread overview]
Message-ID: <6145955.M0qUDR3Ujj@omega> (raw)
The poll test fails on *BSD and Solaris systems, already for years:
Unconnected socket test... passed
Connected sockets test... failed (expecting POLLHUP after shutdown)
General socket test with fork... failed (expecting POLLHUP after shutdown)
Pipe test... passed
FAIL test-poll (exit status: 2)
The test apparently expects POLLHUP for sockets. This is not backed by POSIX
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html>, which
requires POLLHUP to occur only for disconnected devices, pipes, or FIFOs.
So, this part of the test is a Linux-ism.
This patch fixes it.
2020-12-31 Bruno Haible <bruno@clisp.org>
poll tests: Avoid test failure on BSD and Solaris systems.
* tests/test-poll.c (test_accept_first, test_socket_pair): Disable the
"expecting POLLHUP after shutdown" test on all platforms except Linux.
diff --git a/tests/test-poll.c b/tests/test-poll.c
index 3566031..05248d8 100644
--- a/tests/test-poll.c
+++ b/tests/test-poll.c
@@ -280,8 +280,13 @@ test_accept_first (void)
failed ("cannot read data left in the socket by closed process");
ASSERT (read (c, buf, 3) == 3);
ASSERT (write (c, "foo", 3) == 3);
- if ((poll1_wait (c, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+ int revents = poll1_wait (c, POLLIN | POLLOUT);
+# ifdef __linux__
+ if ((revents & (POLLHUP | POLLERR)) == 0)
failed ("expecting POLLHUP after shutdown");
+# else
+ (void) revents;
+# endif
close (c);
}
#endif
@@ -335,8 +340,13 @@ test_socket_pair (void)
test_pair (c1, c2);
close (c1);
ASSERT (write (c2, "foo", 3) == 3);
- if ((poll1_nowait (c2, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+ int revents = poll1_nowait (c2, POLLIN | POLLOUT);
+#ifdef __linux__
+ if ((revents & (POLLHUP | POLLERR)) == 0)
failed ("expecting POLLHUP after shutdown");
+#else
+ (void) revents;
+#endif
close (c2);
}
next reply other threads:[~2020-12-31 22:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-31 22:39 Bruno Haible [this message]
2020-12-31 22:54 ` poll tests: Avoid test failure on AIX Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6145955.M0qUDR3Ujj@omega \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).