X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-dup2.c;h=ecb2692d2af4d25db262c3b473d5903e360497fa;hb=c9451e3bdc651a742f06b46a450497e59bb5e006;hp=5043c0c5bff28f5ffd50e383f5ba7d31408d22dd;hpb=1b612639b0d75ca13f87f3ae5b1eda423cb21655;p=gnulib.git diff --git a/tests/test-dup2.c b/tests/test-dup2.c index 5043c0c5b..ecb2692d2 100644 --- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -1,5 +1,5 @@ /* Test duplicating file descriptors. - Copyright (C) 2009-2012 Free Software Foundation, Inc. + Copyright (C) 2009-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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. */