]> Savannah Git Hosting - gnulib.git/commitdiff
tests: don't assume getdtablesize () <= 10000000
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 29 Apr 2013 22:21:40 +0000 (15:21 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 29 Apr 2013 22:22:03 +0000 (15:22 -0700)
* modules/cloexec-tests:
* modules/dup2-tests:
* modules/dup3-tests:
* modules/nonblocking-tests:
* modules/posix_spawn_file_actions_addclose-tests:
* modules/posix_spawn_file_actions_adddup2-tests:
* modules/posix_spawn_file_actions_addopen-tests:
* modules/unistd-safer-tests:
Depend on the getdtablesize module.
* tests/test-cloexec.c:
* tests/test-dup-safer.c:
* tests/test-dup2.c:
* tests/test-dup3.c:
* tests/test-fcntl.c:
* tests/test-nonblocking.c:
* tests/test-posix_spawn_file_actions_addclose.c:
* tests/test-posix_spawn_file_actions_adddup2.c:
* tests/test-posix_spawn_file_actions_addopen.c:
Don't assume getdtablesize () <= 10000000.

18 files changed:
ChangeLog
modules/cloexec-tests
modules/dup2-tests
modules/dup3-tests
modules/nonblocking-tests
modules/posix_spawn_file_actions_addclose-tests
modules/posix_spawn_file_actions_adddup2-tests
modules/posix_spawn_file_actions_addopen-tests
modules/unistd-safer-tests
tests/test-cloexec.c
tests/test-dup-safer.c
tests/test-dup2.c
tests/test-dup3.c
tests/test-fcntl.c
tests/test-nonblocking.c
tests/test-posix_spawn_file_actions_addclose.c
tests/test-posix_spawn_file_actions_adddup2.c
tests/test-posix_spawn_file_actions_addopen.c

index 49bd6b3244873e1a10298b6141732943d8321706..2c99aa27a10070cea3d3bcd293dc99626a20545c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2013-04-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+       tests: don't assume getdtablesize () <= 10000000
+       * modules/cloexec-tests:
+       * modules/dup2-tests:
+       * modules/dup3-tests:
+       * modules/nonblocking-tests:
+       * modules/posix_spawn_file_actions_addclose-tests:
+       * modules/posix_spawn_file_actions_adddup2-tests:
+       * modules/posix_spawn_file_actions_addopen-tests:
+       * modules/unistd-safer-tests:
+       Depend on the getdtablesize module.
+       * tests/test-cloexec.c:
+       * tests/test-dup-safer.c:
+       * tests/test-dup2.c:
+       * tests/test-dup3.c:
+       * tests/test-fcntl.c:
+       * tests/test-nonblocking.c:
+       * tests/test-posix_spawn_file_actions_addclose.c:
+       * tests/test-posix_spawn_file_actions_adddup2.c:
+       * tests/test-posix_spawn_file_actions_addopen.c:
+       Don't assume getdtablesize () <= 10000000.
+
 2013-04-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        extern-inline: work around bug in Sun c99
index 524716c92eeee9f4eaee6a88a08cbf7603939409..d11fbd144f40e6ecca569efc2b089f0d6abc2d31 100644 (file)
@@ -4,6 +4,7 @@ tests/macros.h
 
 Depends-on:
 binary-io
+getdtablesize
 msvc-nothrow
 
 configure.ac:
index 7893b85aa860a7ec3e8912fc6112b66e2ae184c0..dea1bb1452ce3115ca7d254c5aea1767f01942a5 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 binary-io
 close
 fcntl-h
+getdtablesize
 msvc-nothrow
 open
 
index 03f1cad5e4e8536fde0d977023fc1403e7c79f12..7d527717308cd7e404b1b6754eacf6fbbcbe5eef 100644 (file)
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+getdtablesize
 msvc-nothrow
 open
 close
index b84a32713ff764f29e66f289e3490106ad45797b..e6cb591aace468577a69bbd36726c5ede761010f 100644 (file)
@@ -4,6 +4,7 @@ tests/macros.h
 
 Depends-on:
 close
+getdtablesize
 pipe-posix
 nonblocking-pipe-tests
 nonblocking-socket-tests
index 716ddb2e842f05fe0d66195e448184f200b79e23..848accedfc6e00e0fae3fa07191562a0a5efac3c 100644 (file)
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+getdtablesize
 posix_spawn_file_actions_init
 
 configure.ac:
index 32e0fe55ec718726d6a03bd00267cade8d980056..f504892e4b480dfff06477d62158786304d9e97c 100644 (file)
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+getdtablesize
 posix_spawn_file_actions_init
 
 configure.ac:
index d866c02c70e699b25c6af435bf10124485ce6cc4..fbe7943d49ee665cf08b40a400b8b6f6461d91e4 100644 (file)
@@ -4,6 +4,7 @@ tests/signature.h
 tests/macros.h
 
 Depends-on:
+getdtablesize
 posix_spawn_file_actions_init
 
 configure.ac:
index cd2bbcd34af24cb36d3f7eced8070c4c0fc4143e..c1c09dbc91b19f109c934a77a34c7848fc44c59d 100644 (file)
@@ -8,6 +8,7 @@ cloexec
 close
 dup
 fd-safer-flag
+getdtablesize
 msvc-nothrow
 stdbool
 
index 504a95b99d0354d50ea86bfb388192027ae2e6cd..fe2ca3a88004f4fa1cd77bb1fa814fa97a9ba1d1 100644 (file)
@@ -78,6 +78,7 @@ main (void)
   const char *file = "test-cloexec.tmp";
   int fd = creat (file, 0600);
   int fd2;
+  int bad_fd = getdtablesize ();
 
   /* Assume std descriptors were provided by invoker.  */
   ASSERT (STDERR_FILENO < fd);
@@ -120,7 +121,7 @@ main (void)
   ASSERT (set_cloexec_flag (-1, false) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (set_cloexec_flag (10000000, false) == -1);
+  ASSERT (set_cloexec_flag (bad_fd, false) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
   ASSERT (set_cloexec_flag (fd2, false) == -1);
@@ -129,7 +130,7 @@ main (void)
   ASSERT (dup_cloexec (-1) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (dup_cloexec (10000000) == -1);
+  ASSERT (dup_cloexec (bad_fd) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
   ASSERT (dup_cloexec (fd2) == -1);
index d7567e016d1b695be6f97b50ebf6a4687a064cd5..4dcd752ed26bc27cace99337c3e05082b2fc978f 100644 (file)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <unistd.h>
 
 #include "binary-io.h"
 #include "cloexec.h"
@@ -107,6 +108,7 @@ main (void)
 {
   int i;
   int fd;
+  int bad_fd = getdtablesize ();
 
   /* We close fd 2 later, so save it in fd 10.  */
   if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO
@@ -129,7 +131,7 @@ main (void)
       ASSERT (dup (-1) == -1);
       ASSERT (errno == EBADF);
       errno = 0;
-      ASSERT (dup (10000000) == -1);
+      ASSERT (dup (bad_fd) == -1);
       ASSERT (errno == EBADF);
       close (fd + 1);
       errno = 0;
index 9600c850b16d0e5582e1528e0566ec2ed4ab3a1c..ecb2692d2af4d25db262c3b473d5903e360497fa 100644 (file)
@@ -26,6 +26,10 @@ SIGNATURE_CHECK (dup2, int, (int, int));
 #include <errno.h>
 #include <fcntl.h>
 
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
 #include "binary-io.h"
 
 #if GNULIB_TEST_CLOEXEC
@@ -103,6 +107,7 @@ main (void)
 {
   const char *file = "test-dup2.tmp";
   char buffer[1];
+  int bad_fd = getdtablesize ();
   int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600);
 
   /* Assume std descriptors were provided by invoker.  */
@@ -146,7 +151,7 @@ main (void)
   ASSERT (dup2 (fd, -2) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (dup2 (fd, 10000000) == -1);
+  ASSERT (dup2 (fd, bad_fd) == -1);
   ASSERT (errno == EBADF);
 
   /* Using dup2 can skip fds.  */
index ab2646b095a9d957a7af82d85d4a483a4e9605e6..eb26c8f111bec1265cebdbd0511465c5319b0e39 100644 (file)
@@ -76,6 +76,7 @@ int
 main ()
 {
   int use_cloexec;
+  int bad_fd = getdtablesize ();
 
 #if O_CLOEXEC
   for (use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
@@ -124,7 +125,7 @@ main ()
       ASSERT (dup3 (fd, -2, o_flags) == -1);
       ASSERT (errno == EBADF);
       errno = 0;
-      ASSERT (dup3 (fd, 10000000, o_flags) == -1);
+      ASSERT (dup3 (fd, bad_fd, o_flags) == -1);
       ASSERT (errno == EBADF);
 
       /* Using dup3 can skip fds.  */
index 67d1b41d2f971b74f2a9fc4534034bfd557dfa91..058f30eee44fd6c1341ab658b3a8ab8dbfa042a6 100644 (file)
@@ -211,6 +211,7 @@ main (void)
 {
   const char *file = "test-fcntl.tmp";
   int fd;
+  int bad_fd = getdtablesize ();
 
   /* Sanity check that rpl_fcntl is likely to work.  */
   ASSERT (func2 (1, 2) == 2);
@@ -237,7 +238,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_DUPFD, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_DUPFD, 0) == -1);
+  ASSERT (fcntl (bad_fd, F_DUPFD, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
   ASSERT (fcntl (-1, F_DUPFD_CLOEXEC, 0) == -1);
@@ -246,23 +247,21 @@ main (void)
   ASSERT (fcntl (fd + 1, F_DUPFD_CLOEXEC, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_DUPFD_CLOEXEC, 0) == -1);
+  ASSERT (fcntl (bad_fd, F_DUPFD_CLOEXEC, 0) == -1);
   ASSERT (errno == EBADF);
 
   /* For F_DUPFD*, the destination must be valid.  */
-  ASSERT (getdtablesize () < 10000000);
   errno = 0;
   ASSERT (fcntl (fd, F_DUPFD, -1) == -1);
   ASSERT (errno == EINVAL);
   errno = 0;
-  ASSERT (fcntl (fd, F_DUPFD, 10000000) == -1);
+  ASSERT (fcntl (fd, F_DUPFD, bad_fd) == -1);
   ASSERT (errno == EINVAL);
-  ASSERT (getdtablesize () < 10000000);
   errno = 0;
   ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, -1) == -1);
   ASSERT (errno == EINVAL);
   errno = 0;
-  ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, 10000000) == -1);
+  ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, bad_fd) == -1);
   ASSERT (errno == EINVAL);
 
   /* For F_DUPFD*, check for correct inheritance, as well as
@@ -322,7 +321,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_GETFD) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_GETFD) == -1);
+  ASSERT (fcntl (bad_fd, F_GETFD) == -1);
   ASSERT (errno == EBADF);
 
   /* Test F_GETFD, the FD_CLOEXEC bit.  */
@@ -346,7 +345,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_SETFD, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_SETFD, 0) == -1);
+  ASSERT (fcntl (bad_fd, F_SETFD, 0) == -1);
   ASSERT (errno == EBADF);
 #endif
 
@@ -359,7 +358,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_GETFL) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_GETFL) == -1);
+  ASSERT (fcntl (bad_fd, F_GETFL) == -1);
   ASSERT (errno == EBADF);
 #endif
 
@@ -372,7 +371,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_SETFL, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_SETFL, 0) == -1);
+  ASSERT (fcntl (bad_fd, F_SETFL, 0) == -1);
   ASSERT (errno == EBADF);
 #endif
 
@@ -385,7 +384,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_GETOWN) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_GETOWN) == -1);
+  ASSERT (fcntl (bad_fd, F_GETOWN) == -1);
   ASSERT (errno == EBADF);
 #endif
 
@@ -398,7 +397,7 @@ main (void)
   ASSERT (fcntl (fd + 1, F_SETOWN, 0) == -1);
   ASSERT (errno == EBADF);
   errno = 0;
-  ASSERT (fcntl (10000000, F_SETOWN, 0) == -1);
+  ASSERT (fcntl (bad_fd, F_SETOWN, 0) == -1);
   ASSERT (errno == EBADF);
 #endif
 
index 6b52167cb77d72879e01f1221a670bd92614acc1..aa7de78532217e968b69f4d07c505de031ff70b2 100644 (file)
@@ -124,7 +124,7 @@ main (void)
   }
   {
     errno = 0;
-    ASSERT (set_nonblocking_flag (10000000, false) == -1);
+    ASSERT (set_nonblocking_flag (getdtablesize (), false) == -1);
     ASSERT (errno == EBADF);
   }
 
index ae149246ce10325a1711a8cb7bb73b336d15bbbc..47b12d0f2b9ede8b11e9684f08af06d00ebc7643 100644 (file)
@@ -23,6 +23,7 @@ SIGNATURE_CHECK (posix_spawn_file_actions_addclose, int,
                  (posix_spawn_file_actions_t *, int));
 
 #include <errno.h>
+#include <unistd.h>
 
 #include "macros.h"
 
@@ -40,7 +41,8 @@ main (void)
   }
   {
     errno = 0;
-    ASSERT (posix_spawn_file_actions_addclose (&actions, 10000000) == EBADF);
+    ASSERT (posix_spawn_file_actions_addclose (&actions, getdtablesize ())
+            == EBADF);
   }
 
   return 0;
index f6173043cae9983106e1aac9a47df9a5f19ba4e7..d728eff61c595fe04368e5830f9a13526ba85868 100644 (file)
@@ -23,12 +23,14 @@ SIGNATURE_CHECK (posix_spawn_file_actions_adddup2, int,
                  (posix_spawn_file_actions_t *, int, int));
 
 #include <errno.h>
+#include <unistd.h>
 
 #include "macros.h"
 
 int
 main (void)
 {
+  int bad_fd = getdtablesize ();
   posix_spawn_file_actions_t actions;
 
   ASSERT (posix_spawn_file_actions_init (&actions) == 0);
@@ -40,7 +42,7 @@ main (void)
   }
   {
     errno = 0;
-    ASSERT (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == EBADF);
+    ASSERT (posix_spawn_file_actions_adddup2 (&actions, bad_fd, 2) == EBADF);
   }
   {
     errno = 0;
@@ -48,7 +50,7 @@ main (void)
   }
   {
     errno = 0;
-    ASSERT (posix_spawn_file_actions_adddup2 (&actions, 2, 10000000) == EBADF);
+    ASSERT (posix_spawn_file_actions_adddup2 (&actions, 2, bad_fd) == EBADF);
   }
 
   return 0;
index d2920f1388da3a1145b28d906cf12d4dc9107a0a..c2329d4fc1843ddec5db247a7077b6c03e0e21cb 100644 (file)
@@ -25,6 +25,7 @@ SIGNATURE_CHECK (posix_spawn_file_actions_addopen, int,
 
 #include <errno.h>
 #include <fcntl.h>
+#include <unistd.h>
 
 #include "macros.h"
 
@@ -44,7 +45,7 @@ main (void)
   }
   {
     errno = 0;
-    ASSERT (posix_spawn_file_actions_addopen (&actions, 10000000,
+    ASSERT (posix_spawn_file_actions_addopen (&actions, getdtablesize (),
                                               "foo", 0, O_RDONLY)
             == EBADF);
   }