+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
Depends-on:
binary-io
+getdtablesize
msvc-nothrow
configure.ac:
binary-io
close
fcntl-h
+getdtablesize
msvc-nothrow
open
tests/macros.h
Depends-on:
+getdtablesize
msvc-nothrow
open
close
Depends-on:
close
+getdtablesize
pipe-posix
nonblocking-pipe-tests
nonblocking-socket-tests
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
tests/macros.h
Depends-on:
+getdtablesize
posix_spawn_file_actions_init
configure.ac:
close
dup
fd-safer-flag
+getdtablesize
msvc-nothrow
stdbool
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);
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);
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);
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
+#include <unistd.h>
#include "binary-io.h"
#include "cloexec.h"
{
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
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;
#include <errno.h>
#include <fcntl.h>
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
#include "binary-io.h"
#if GNULIB_TEST_CLOEXEC
{
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. */
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. */
main ()
{
int use_cloexec;
+ int bad_fd = getdtablesize ();
#if O_CLOEXEC
for (use_cloexec = 0; use_cloexec <= 1; use_cloexec++)
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. */
{
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);
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);
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
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. */
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
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
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
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
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
}
{
errno = 0;
- ASSERT (set_nonblocking_flag (10000000, false) == -1);
+ ASSERT (set_nonblocking_flag (getdtablesize (), false) == -1);
ASSERT (errno == EBADF);
}
(posix_spawn_file_actions_t *, int));
#include <errno.h>
+#include <unistd.h>
#include "macros.h"
}
{
errno = 0;
- ASSERT (posix_spawn_file_actions_addclose (&actions, 10000000) == EBADF);
+ ASSERT (posix_spawn_file_actions_addclose (&actions, getdtablesize ())
+ == EBADF);
}
return 0;
(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);
}
{
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;
}
{
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;
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#include "macros.h"
}
{
errno = 0;
- ASSERT (posix_spawn_file_actions_addopen (&actions, 10000000,
+ ASSERT (posix_spawn_file_actions_addopen (&actions, getdtablesize (),
"foo", 0, O_RDONLY)
== EBADF);
}