bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* poll tests: Avoid test failure on BSD and Solaris systems
@ 2020-12-31 22:39 Bruno Haible
  2020-12-31 22:54 ` poll tests: Avoid test failure on AIX Bruno Haible
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2020-12-31 22:39 UTC (permalink / raw)
  To: bug-gnulib

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* poll tests: Avoid test failure on AIX
  2020-12-31 22:39 poll tests: Avoid test failure on BSD and Solaris systems Bruno Haible
@ 2020-12-31 22:54 ` Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2020-12-31 22:54 UTC (permalink / raw)
  To: bug-gnulib

Another POLLHUP test is failing on AIX, but here not for the sockets,
but for the pipes. This is an AIX bug w.r.t. POSIX. Since we cannot
easily work around it in Gnulib, this patch
  - documents it,
  - avoids a test failure (since I don't want to see it over and over
    again, now that it's documented).


2020-12-31  Bruno Haible  <bruno@clisp.org>

	poll tests: Avoid test failure on AIX.
	* tests/test-poll.c (test_pipe): Disable the "expecting POLLHUP after
	shutdown" test on AIX.
	* doc/posix-functions/poll.texi: Mention the AIX bug.

diff --git a/doc/posix-functions/poll.texi b/doc/posix-functions/poll.texi
index a04d3b8..c1efe87 100644
--- a/doc/posix-functions/poll.texi
+++ b/doc/posix-functions/poll.texi
@@ -23,8 +23,8 @@ Portability problems not fixed by Gnulib:
 Under Windows, when passing a pipe, Gnulib's @code{poll} replacement might
 return 0 even before the timeout has passed.  Programs using it with pipes can
 thus busy wait.
-
 @item
-Under HP NonStop, file descriptors other than sockets do not support
-POLLHUP; they will return a "readable" status instead.
+On some platforms, file descriptors other than sockets do not support
+POLLHUP; they will return a "readable" or "writable" status instead:
+AIX 7.2, HP NonStop.
 @end itemize
diff --git a/tests/test-poll.c b/tests/test-poll.c
index 05248d8..5105620 100644
--- a/tests/test-poll.c
+++ b/tests/test-poll.c
@@ -362,8 +362,13 @@ test_pipe (void)
   ASSERT (pipe (fd) >= 0);
   test_pair (fd[0], fd[1]);
   close (fd[0]);
-  if ((poll1_wait (fd[1], POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+  int revents = poll1_wait (fd[1], POLLIN | POLLOUT);
+#if !defined _AIX
+  if ((revents & (POLLHUP | POLLERR)) == 0)
     failed ("expecting POLLHUP after shutdown");
+#else
+  (void) revents;
+#endif
 
   close (fd[1]);
 }



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-31 23:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 22:39 poll tests: Avoid test failure on BSD and Solaris systems Bruno Haible
2020-12-31 22:54 ` poll tests: Avoid test failure on AIX Bruno Haible

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).