bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 02/10] test-pselect: new module


From: Paul Eggert
Subject: [PATCH 02/10] test-pselect: new module
Date: Wed, 06 Jul 2011 00:54:27 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10

* modules/pselect-tests, tests/test-pselect.c: New files.
* tests/test-select.c, tests/test-sys_select-c++.cc:
If TEST_PSELECT is defined, test pselect instead of testing select.
---
 ChangeLog                    |    5 +++++
 modules/pselect-tests        |   12 ++++++++++++
 tests/test-pselect.c         |    2 ++
 tests/test-select.c          |   21 +++++++++++++++++++++
 tests/test-sys_select-c++.cc |    6 ++++++
 5 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 modules/pselect-tests
 create mode 100644 tests/test-pselect.c

diff --git a/ChangeLog b/ChangeLog
index aca6253..70b1c51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-07-05  Paul Eggert  <address@hidden>
 
+       test-pselect: new module
+       * modules/pselect-tests, tests/test-pselect.c: New files.
+       * tests/test-select.c, tests/test-sys_select-c++.cc:
+       If TEST_PSELECT is defined, test pselect instead of testing select.
+
        * tests/test-sys_select.c (sigset_t): Test for it, too.
        Suggested by Bruno Haible.
 
diff --git a/modules/pselect-tests b/modules/pselect-tests
new file mode 100644
index 0000000..0a405fc
--- /dev/null
+++ b/modules/pselect-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-pselect.c
+
+Depends-on:
+select-tests
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-pselect
+check_PROGRAMS += test-pselect
+test_pselect_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
diff --git a/tests/test-pselect.c b/tests/test-pselect.c
new file mode 100644
index 0000000..1d80fe0
--- /dev/null
+++ b/tests/test-pselect.c
@@ -0,0 +1,2 @@
+#define TEST_PSELECT
+#include "test-select.c"
diff --git a/tests/test-select.c b/tests/test-select.c
index 5c15320..9e927f8 100644
--- a/tests/test-select.c
+++ b/tests/test-select.c
@@ -21,8 +21,16 @@
 #include <sys/select.h>
 
 #include "signature.h"
+
+#ifdef TEST_PSELECT
+SIGNATURE_CHECK (pselect, int,
+                 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                  struct timespec const *restrict, const sigset_t *restrict));
+#else
 SIGNATURE_CHECK (select, int, (int, fd_set *, fd_set *, fd_set *,
                                struct timeval *));
+#endif
+
 /* The following may be macros without underlying functions, so only
    check signature if they are not macros.  */
 #ifndef FD_CLR
@@ -190,7 +198,20 @@ do_select (int fd, int ev, struct timeval *timeout)
     FD_SET (fd, &wfds);
   if (ev & SEL_EXC)
     FD_SET (fd, &xfds);
+#ifdef TEST_PSELECT
+  {
+    struct timespec ts, *pts = NULL;
+    if (timeout)
+      {
+        ts.tv_sec = timeout->tv_sec;
+        ts.tv_nsec = timeout->tv_usec * 1000;
+        pts = &ts;
+      }
+    r = pselect (fd + 1, &rfds, &wfds, &xfds, pts, NULL);
+  }
+#else
   r = select (fd + 1, &rfds, &wfds, &xfds, timeout);
+#endif
   if (r < 0)
     return r;
 
diff --git a/tests/test-sys_select-c++.cc b/tests/test-sys_select-c++.cc
index 8279d9a..311b8f0 100644
--- a/tests/test-sys_select-c++.cc
+++ b/tests/test-sys_select-c++.cc
@@ -24,6 +24,12 @@
 #include "signature.h"
 
 
+#if GNULIB_TEST_PSELECT
+SIGNATURE_CHECK (GNULIB_NAMESPACE::pselect, int,
+                 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                  struct timespec const *restrict, sigset_t const *restrict));
+#endif
+
 #if GNULIB_TEST_SELECT
 SIGNATURE_CHECK (GNULIB_NAMESPACE::select, int,
                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
-- 
1.7.4.4



reply via email to

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