bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 5/4] nonblocking: reduce dependency


From: Eric Blake
Subject: [PATCH 5/4] nonblocking: reduce dependency
Date: Fri, 8 Apr 2011 12:39:56 -0600

No need to make nonblocking drag in sockets just for a test;
test them if they are present and skip them otherwise.

* tests/test-nonblocking.c: Only test sockets when in use.
* modules/nonblocking-tests (Depends-on): Drop socket.
(Makefile.am): Link even if sockets are not present.
* modules/pipe2-tests (Makefile.am): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---

This reduces the bulk for test-pipe2 in isolation, but still works
when the sockets module is also in use.  @LIBSOCKET@ is unconditional,
whereas $(LIBSOCKET) is tolerant of no socket library.

 ChangeLog                 |    6 ++++++
 modules/nonblocking-tests |    3 +--
 modules/pipe2-tests       |    2 +-
 tests/test-nonblocking.c  |   11 ++++++-----
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a8d4521..2e8791b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-04-08  Eric Blake  <address@hidden>

+       nonblocking: reduce dependency
+       * tests/test-nonblocking.c: Only test sockets when in use.
+       * modules/nonblocking-tests (Depends-on): Drop socket.
+       (Makefile.am): Link even if sockets are not present.
+       * modules/pipe2-tests (Makefile.am): Likewise.
+
        pipe2: fix O_NONBLOCK support on mingw
        * modules/pipe2 (Depends-on): Add nonblocking.
        * lib/pipe2.c (pipe2) [WIN32]: Add O_NONBLOCK support.
diff --git a/modules/nonblocking-tests b/modules/nonblocking-tests
index 34d206d..a1e5e7c 100644
--- a/modules/nonblocking-tests
+++ b/modules/nonblocking-tests
@@ -5,11 +5,10 @@ tests/macros.h
 Depends-on:
 close
 pipe-posix
-socket

 configure.ac:

 Makefile.am:
 TESTS += test-nonblocking
 check_PROGRAMS += test-nonblocking
-test_nonblocking_LDADD = $(LDADD) @LIBSOCKET@
+test_nonblocking_LDADD = $(LDADD) $(LIBSOCKET)
diff --git a/modules/pipe2-tests b/modules/pipe2-tests
index 9e751dc..2e6c3f7 100644
--- a/modules/pipe2-tests
+++ b/modules/pipe2-tests
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-pipe2
 check_PROGRAMS += test-pipe2
-test_pipe2_LDADD = $(LDADD) @LIBSOCKET@
+test_pipe2_LDADD = $(LDADD) $(LIBSOCKET)
diff --git a/tests/test-nonblocking.c b/tests/test-nonblocking.c
index f1b7610..a9fc369 100644
--- a/tests/test-nonblocking.c
+++ b/tests/test-nonblocking.c
@@ -79,14 +79,14 @@ main (void)
   ASSERT (close (fd_pipe[1]) == 0);

 #if GNULIB_TEST_PIPE2
-  /* mingw still lacks O_NONBLOCK replacement.  */
   ASSERT (pipe2 (fd_pipe, O_NONBLOCK) == 0);
-  ASSERT (get_nonblocking_flag (fd_pipe[0]) == !!O_NONBLOCK);
-  ASSERT (get_nonblocking_flag (fd_pipe[1]) == !!O_NONBLOCK);
+  ASSERT (get_nonblocking_flag (fd_pipe[0]) == 1);
+  ASSERT (get_nonblocking_flag (fd_pipe[1]) == 1);
   ASSERT (close (fd_pipe[0]) == 0);
   ASSERT (close (fd_pipe[1]) == 0);
 #endif /* GNULIB_TEST_PIPE2 */

+#if GNULIB_SOCKET
   /* Test sockets.  */
   fd_sock = socket (AF_INET, SOCK_STREAM, 0);
   ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 0 : -1));
@@ -96,11 +96,12 @@ main (void)
   ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 0 : -1));
   ASSERT (close (fd_sock) == 0);

-#if SOCK_NONBLOCK
+# if SOCK_NONBLOCK
   fd_sock = socket (AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
   ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 1 : -1));
   ASSERT (close (fd_sock) == 0);
-#endif /* SOCK_NONBLOCK */
+# endif /* SOCK_NONBLOCK */
+#endif /* GNULIB_SOCKET */

   /* Test error handling.  */
   {
-- 
1.7.4.2




reply via email to

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