bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

poll tests: Avoid test failure on BSD and Solaris systems


From: Bruno Haible
Subject: poll tests: Avoid test failure on BSD and Solaris systems
Date: Thu, 31 Dec 2020 23:39:09 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; )

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);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]