X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-dup2.c;h=ecb2692d2af4d25db262c3b473d5903e360497fa;hb=c9451e3bdc651a742f06b46a450497e59bb5e006;hp=80514a19f6350a09cae86b34473fb51beb5aad93;hpb=9fc81090f6c5590bd1b0e0fa5087577a2ee43a3e;p=gnulib.git diff --git a/tests/test-dup2.c b/tests/test-dup2.c index 80514a19f..ecb2692d2 100644 --- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -26,6 +26,10 @@ SIGNATURE_CHECK (dup2, int, (int, int)); #include #include +#if HAVE_SYS_RESOURCE_H +# include +#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. */ @@ -122,6 +127,7 @@ main (void) errno = 0; ASSERT (dup2 (-1, fd) == -1); ASSERT (errno == EBADF); + close (99); 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, 10000000) == -1); + ASSERT (dup2 (fd, bad_fd) == -1); ASSERT (errno == EBADF); /* Using dup2 can skip fds. */