[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: don't assume getdtablesize () <= 10000000
From: |
Paul Eggert |
Subject: |
[PATCH] tests: don't assume getdtablesize () <= 10000000 |
Date: |
Mon, 29 Apr 2013 15:23:45 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
---
ChangeLog | 23 +++++++++++++++++++++++
modules/cloexec-tests | 1 +
modules/dup2-tests | 1 +
modules/dup3-tests | 1 +
modules/nonblocking-tests | 1 +
modules/posix_spawn_file_actions_addclose-tests | 1 +
modules/posix_spawn_file_actions_adddup2-tests | 1 +
modules/posix_spawn_file_actions_addopen-tests | 1 +
modules/unistd-safer-tests | 1 +
tests/test-cloexec.c | 5 +++--
tests/test-dup-safer.c | 4 +++-
tests/test-dup2.c | 7 ++++++-
tests/test-dup3.c | 3 ++-
tests/test-fcntl.c | 23 +++++++++++------------
tests/test-nonblocking.c | 2 +-
tests/test-posix_spawn_file_actions_addclose.c | 4 +++-
tests/test-posix_spawn_file_actions_adddup2.c | 6 ++++--
tests/test-posix_spawn_file_actions_addopen.c | 3 ++-
18 files changed, 66 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 49bd6b3..2c99aa2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2013-04-29 Paul Eggert <address@hidden>
+
+ 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 <address@hidden>
extern-inline: work around bug in Sun c99
diff --git a/modules/cloexec-tests b/modules/cloexec-tests
index 524716c..d11fbd1 100644
--- a/modules/cloexec-tests
+++ b/modules/cloexec-tests
@@ -4,6 +4,7 @@ tests/macros.h
Depends-on:
binary-io
+getdtablesize
msvc-nothrow
configure.ac:
diff --git a/modules/dup2-tests b/modules/dup2-tests
index 7893b85..dea1bb1 100644
--- a/modules/dup2-tests
+++ b/modules/dup2-tests
@@ -7,6 +7,7 @@ Depends-on:
binary-io
close
fcntl-h
+getdtablesize
msvc-nothrow
open
diff --git a/modules/dup3-tests b/modules/dup3-tests
index 03f1cad..7d52771 100644
--- a/modules/dup3-tests
+++ b/modules/dup3-tests
@@ -4,6 +4,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+getdtablesize
msvc-nothrow
open
close
diff --git a/modules/nonblocking-tests b/modules/nonblocking-tests
index b84a327..e6cb591 100644
--- a/modules/nonblocking-tests
+++ b/modules/nonblocking-tests
@@ -4,6 +4,7 @@ tests/macros.h
Depends-on:
close
+getdtablesize
pipe-posix
nonblocking-pipe-tests
nonblocking-socket-tests
diff --git a/modules/posix_spawn_file_actions_addclose-tests
b/modules/posix_spawn_file_actions_addclose-tests
index 716ddb2..848acce 100644
--- a/modules/posix_spawn_file_actions_addclose-tests
+++ b/modules/posix_spawn_file_actions_addclose-tests
@@ -4,6 +4,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
diff --git a/modules/posix_spawn_file_actions_adddup2-tests
b/modules/posix_spawn_file_actions_adddup2-tests
index 32e0fe5..f504892 100644
--- a/modules/posix_spawn_file_actions_adddup2-tests
+++ b/modules/posix_spawn_file_actions_adddup2-tests
@@ -4,6 +4,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
diff --git a/modules/posix_spawn_file_actions_addopen-tests
b/modules/posix_spawn_file_actions_addopen-tests
index d866c02..fbe7943 100644
--- a/modules/posix_spawn_file_actions_addopen-tests
+++ b/modules/posix_spawn_file_actions_addopen-tests
@@ -4,6 +4,7 @@ tests/signature.h
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
diff --git a/modules/unistd-safer-tests b/modules/unistd-safer-tests
index cd2bbcd..c1c09db 100644
--- a/modules/unistd-safer-tests
+++ b/modules/unistd-safer-tests
@@ -8,6 +8,7 @@ cloexec
close
dup
fd-safer-flag
+getdtablesize
msvc-nothrow
stdbool
diff --git a/tests/test-cloexec.c b/tests/test-cloexec.c
index 504a95b..fe2ca3a 100644
--- a/tests/test-cloexec.c
+++ b/tests/test-cloexec.c
@@ -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);
diff --git a/tests/test-dup-safer.c b/tests/test-dup-safer.c
index d7567e0..4dcd752 100644
--- a/tests/test-dup-safer.c
+++ b/tests/test-dup-safer.c
@@ -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;
diff --git a/tests/test-dup2.c b/tests/test-dup2.c
index 9600c85..ecb2692 100644
--- a/tests/test-dup2.c
+++ b/tests/test-dup2.c
@@ -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. */
diff --git a/tests/test-dup3.c b/tests/test-dup3.c
index ab2646b..eb26c8f 100644
--- a/tests/test-dup3.c
+++ b/tests/test-dup3.c
@@ -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. */
diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c
index 67d1b41..058f30e 100644
--- a/tests/test-fcntl.c
+++ b/tests/test-fcntl.c
@@ -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
diff --git a/tests/test-nonblocking.c b/tests/test-nonblocking.c
index 6b52167..aa7de78 100644
--- a/tests/test-nonblocking.c
+++ b/tests/test-nonblocking.c
@@ -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);
}
diff --git a/tests/test-posix_spawn_file_actions_addclose.c
b/tests/test-posix_spawn_file_actions_addclose.c
index ae14924..47b12d0 100644
--- a/tests/test-posix_spawn_file_actions_addclose.c
+++ b/tests/test-posix_spawn_file_actions_addclose.c
@@ -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;
diff --git a/tests/test-posix_spawn_file_actions_adddup2.c
b/tests/test-posix_spawn_file_actions_adddup2.c
index f617304..d728eff 100644
--- a/tests/test-posix_spawn_file_actions_adddup2.c
+++ b/tests/test-posix_spawn_file_actions_adddup2.c
@@ -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;
diff --git a/tests/test-posix_spawn_file_actions_addopen.c
b/tests/test-posix_spawn_file_actions_addopen.c
index d2920f1..c2329d4 100644
--- a/tests/test-posix_spawn_file_actions_addopen.c
+++ b/tests/test-posix_spawn_file_actions_addopen.c
@@ -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);
}
--
1.7.11.7
- [PATCH] tests: don't assume getdtablesize () <= 10000000,
Paul Eggert <=