+2013-06-11 Paul Eggert <eggert@cs.ucla.edu>
+
+ tests: port large-fd POSIX spawn tests to OS X
+ Problem reported by Daiki Ueno in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2013-06/msg00031.html>.
+ * tests/test-posix_spawn_file_actions_addclose.c:
+ * tests/test-posix_spawn_file_actions_adddup2.c:
+ * tests/test-posix_spawn_file_actions_addopen.c:
+ Include <limits.h>, for OPEN_MAX, if available.
+ (big_fd): New static function.
+ (main): Use it.
+
2013-06-04 Bernhard Voelker <mail@bernhard-voelker.de>
tests/nap.h: use an adaptive delay to avoid ctime update issues
(posix_spawn_file_actions_t *, int));
#include <errno.h>
+#include <limits.h>
#include <unistd.h>
#include "macros.h"
+/* Return a file descriptor that is too big to use.
+ Prefer the smallest such fd, except use OPEN_MAX if it is defined
+ and is greater than getdtablesize (), as that's how OS X works. */
+static int
+big_fd (void)
+{
+ int fd = getdtablesize ();
+#ifdef OPEN_MAX
+ if (fd < OPEN_MAX)
+ fd = OPEN_MAX;
+#endif
+ return fd;
+}
+
int
main (void)
{
ASSERT (posix_spawn_file_actions_addclose (&actions, -1) == EBADF);
}
{
+ int bad_fd = big_fd ();
errno = 0;
- ASSERT (posix_spawn_file_actions_addclose (&actions, getdtablesize ())
- == EBADF);
+ ASSERT (posix_spawn_file_actions_addclose (&actions, bad_fd) == EBADF);
}
return 0;
(posix_spawn_file_actions_t *, int, int));
#include <errno.h>
+#include <limits.h>
#include <unistd.h>
#include "macros.h"
+/* Return a file descriptor that is too big to use.
+ Prefer the smallest such fd, except use OPEN_MAX if it is defined
+ and is greater than getdtablesize (), as that's how OS X works. */
+static int
+big_fd (void)
+{
+ int fd = getdtablesize ();
+#ifdef OPEN_MAX
+ if (fd < OPEN_MAX)
+ fd = OPEN_MAX;
+#endif
+ return fd;
+}
+
int
main (void)
{
- int bad_fd = getdtablesize ();
+ int bad_fd = big_fd ();
posix_spawn_file_actions_t actions;
ASSERT (posix_spawn_file_actions_init (&actions) == 0);
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
#include <unistd.h>
#include "macros.h"
+/* Return a file descriptor that is too big to use.
+ Prefer the smallest such fd, except use OPEN_MAX if it is defined
+ and is greater than getdtablesize (), as that's how OS X works. */
+static int
+big_fd (void)
+{
+ int fd = getdtablesize ();
+#ifdef OPEN_MAX
+ if (fd < OPEN_MAX)
+ fd = OPEN_MAX;
+#endif
+ return fd;
+}
+
int
main (void)
{
== EBADF);
}
{
+ int bad_fd = big_fd ();
errno = 0;
- ASSERT (posix_spawn_file_actions_addopen (&actions, getdtablesize (),
+ ASSERT (posix_spawn_file_actions_addopen (&actions, bad_fd,
"foo", 0, O_RDONLY)
== EBADF);
}