While investigating skipped tests on FreeBSD I found that test-poll
and test-select were skipped due to bind() returning EADDRINUSE.  It
turns out that these tests call setsockopt(..., SO_REUSE... after
calling bind(), not before.

diff --git a/tests/test-poll.c b/tests/test-poll.c
index 7ba0280..69a30f0 100644
--- a/tests/test-poll.c
+++ b/tests/test-poll.c
@@ -96,6 +96,9 @@ open_server_socket ()

   s = socket (AF_INET, SOCK_STREAM, 0);

+  x = 1;
+++ b/tests/test-poll.c
@@ -96,6 +96,9 @@ open_server_socket ()

   s = socket (AF_INET, SOCK_STREAM, 0);

+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
   memset (&ia, 0, sizeof (ia));
   ia.sin_family = AF_INET;
   inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
@@ -106,9 +109,6 @@ open_server_socket ()
       exit (77);
     }

-  x = 1;
-  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
-
   if (listen (s, 1) < 0)
     {
       perror ("listen");
diff --git a/tests/test-select.h b/tests/test-select.h
index 1169e59..af0e38c 100644
--- a/tests/test-select.h
+++ b/tests/test-select.h
@@ -84,6 +84,9 @@ open_server_socket (void)

   s = socket (AF_INET, SOCK_STREAM, 0);

+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
   memset (&ia, 0, sizeof (ia));
   ia.sin_family = AF_INET;
   inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
@@ -94,9 +97,6 @@ open_server_socket (void)
       exit (77);
     }

Reply via email to