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 <br...@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); }