projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
selinux-at: omit unnecessary include
[gnulib.git]
/
tests
/
test-dup2.c
diff --git
a/tests/test-dup2.c
b/tests/test-dup2.c
index
80514a1
..
ecb2692
100644
(file)
--- 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>
#include <errno.h>
#include <fcntl.h>
+#if HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
#include "binary-io.h"
#if GNULIB_TEST_CLOEXEC
#include "binary-io.h"
#if GNULIB_TEST_CLOEXEC
@@
-103,6
+107,7
@@
main (void)
{
const char *file = "test-dup2.tmp";
char buffer[1];
{
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. */
int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600);
/* Assume std descriptors were provided by invoker. */
@@
-122,6
+127,7
@@
main (void)
errno = 0;
ASSERT (dup2 (-1, fd) == -1);
ASSERT (errno == EBADF);
errno = 0;
ASSERT (dup2 (-1, fd) == -1);
ASSERT (errno == EBADF);
+ close (99);
errno = 0;
ASSERT (dup2 (99, fd) == -1);
ASSERT (errno == EBADF);
errno = 0;
ASSERT (dup2 (99, fd) == -1);
ASSERT (errno == EBADF);
@@
-145,7
+151,7
@@
main (void)
ASSERT (dup2 (fd, -2) == -1);
ASSERT (errno == EBADF);
errno = 0;
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. */
ASSERT (errno == EBADF);
/* Using dup2 can skip fds. */