Mercurial > hg > octave-kai > gnulib-hg
changeset 17295:3a09cc104f4c
tests: don't assume fd 99 is closed
* tests/test-accept.c, tests/test-accept4.c, tests/test-bind.c:
* tests/test-close.c, tests/test-connect.c, tests/test-dprintf.c:
* tests/test-dup.c, tests/test-dup2.c, tests/test-faccessat.c:
* tests/test-fchdir.c, tests/test-fchmod.c, tests/test-fchmodat.c:
* tests/test-fchown.c, tests/test-fchownat.c, tests/test-fclose.c:
* tests/test-fdatasync.c, tests/test-fdopen.c, tests/test-fdopendir.c:
* tests/test-fflush.c, tests/test-fgetc.c, tests/test-fputc.c:
* tests/test-fread.c, tests/test-freopen.c, tests/test-fseeko4.c:
* tests/test-fstat.c, tests/test-fstatat.c, tests/test-fsync.c:
* tests/test-ftello4.c, tests/test-ftruncate.c, tests/test-futimens.h:
* tests/test-fwrite.c, tests/test-getpeername.c:
* tests/test-getsockname.c, tests/test-getsockopt.c:
* tests/test-grantpt.c, tests/test-ioctl.c, tests/test-isatty.c:
* tests/test-linkat.c, tests/test-listen.c, tests/test-lseek.c:
* tests/test-mkdirat.c, tests/test-mkfifoat.c, tests/test-openat.c:
* tests/test-pread.c, tests/test-pwrite.c, tests/test-read.c:
* tests/test-readlinkat.c, tests/test-recv.c, tests/test-recvfrom.c:
* tests/test-renameat.c, tests/test-select.h, tests/test-send.c:
* tests/test-sendto.c, tests/test-setsockopt.c, tests/test-shutdown.c:
* tests/test-symlinkat.c, tests/test-ttyname_r.c:
* tests/test-unlinkat.c, tests/test-unlockpt.c:
* tests/test-utimensat.c, tests/test-vdprintf.c, tests/test-write.c:
Close file descriptor 99, instead of assuming it's already closed.
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2013-01-22 Paul Eggert <eggert@cs.ucla.edu> + + tests: don't assume fd 99 is closed + * tests/test-accept.c, tests/test-accept4.c, tests/test-bind.c: + * tests/test-close.c, tests/test-connect.c, tests/test-dprintf.c: + * tests/test-dup.c, tests/test-dup2.c, tests/test-faccessat.c: + * tests/test-fchdir.c, tests/test-fchmod.c, tests/test-fchmodat.c: + * tests/test-fchown.c, tests/test-fchownat.c, tests/test-fclose.c: + * tests/test-fdatasync.c, tests/test-fdopen.c, tests/test-fdopendir.c: + * tests/test-fflush.c, tests/test-fgetc.c, tests/test-fputc.c: + * tests/test-fread.c, tests/test-freopen.c, tests/test-fseeko4.c: + * tests/test-fstat.c, tests/test-fstatat.c, tests/test-fsync.c: + * tests/test-ftello4.c, tests/test-ftruncate.c, tests/test-futimens.h: + * tests/test-fwrite.c, tests/test-getpeername.c: + * tests/test-getsockname.c, tests/test-getsockopt.c: + * tests/test-grantpt.c, tests/test-ioctl.c, tests/test-isatty.c: + * tests/test-linkat.c, tests/test-listen.c, tests/test-lseek.c: + * tests/test-mkdirat.c, tests/test-mkfifoat.c, tests/test-openat.c: + * tests/test-pread.c, tests/test-pwrite.c, tests/test-read.c: + * tests/test-readlinkat.c, tests/test-recv.c, tests/test-recvfrom.c: + * tests/test-renameat.c, tests/test-select.h, tests/test-send.c: + * tests/test-sendto.c, tests/test-setsockopt.c, tests/test-shutdown.c: + * tests/test-symlinkat.c, tests/test-ttyname_r.c: + * tests/test-unlinkat.c, tests/test-unlockpt.c: + * tests/test-utimensat.c, tests/test-vdprintf.c, tests/test-write.c: + Close file descriptor 99, instead of assuming it's already closed. + 2013-01-21 Paul Eggert <eggert@cs.ucla.edu> stpncpy: port to OS X 10.8
--- a/tests/test-accept.c +++ b/tests/test-accept.c @@ -45,6 +45,7 @@ struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); + close (99); errno = 0; ASSERT (accept (99, (struct sockaddr *) &addr, &addrlen) == -1); ASSERT (errno == EBADF);
--- a/tests/test-accept4.c +++ b/tests/test-accept4.c @@ -50,6 +50,7 @@ struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); + close (99); errno = 0; ASSERT (accept4 (99, (struct sockaddr *) &addr, &addrlen, O_CLOEXEC | O_BINARY)
--- a/tests/test-bind.c +++ b/tests/test-bind.c @@ -46,6 +46,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (bind (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1); ASSERT (errno == EBADF);
--- a/tests/test-close.c +++ b/tests/test-close.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (close (99) == -1); ASSERT (errno == EBADF);
--- a/tests/test-connect.c +++ b/tests/test-connect.c @@ -47,6 +47,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (connect (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1);
--- a/tests/test-dprintf.c +++ b/tests/test-dprintf.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (dprintf (99, "test") == -1); ASSERT (errno == EBADF);
--- a/tests/test-dup.c +++ b/tests/test-dup.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (dup (99) == -1); ASSERT (errno == EBADF);
--- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -122,6 +122,7 @@ errno = 0; ASSERT (dup2 (-1, fd) == -1); ASSERT (errno == EBADF); + close (99); errno = 0; ASSERT (dup2 (99, fd) == -1); ASSERT (errno == EBADF);
--- a/tests/test-faccessat.c +++ b/tests/test-faccessat.c @@ -36,6 +36,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (faccessat (99, "foo", F_OK, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fchdir.c +++ b/tests/test-fchdir.c @@ -51,6 +51,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fchdir (99) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fchmod.c +++ b/tests/test-fchmod.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fchmod (99, 0600) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fchmodat.c +++ b/tests/test-fchmodat.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fchmodat (99, "foo", 0600, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fchown.c +++ b/tests/test-fchown.c @@ -35,6 +35,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fchown (99, getuid (), getgid ()) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fchownat.c +++ b/tests/test-fchownat.c @@ -76,6 +76,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fchownat (99, "foo", getuid (), getgid (), 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fclose.c +++ b/tests/test-fclose.c @@ -96,7 +96,9 @@ } } { - FILE *fp = fdopen (99, "r"); + FILE *fp; + close (99); + fp = fdopen (99, "r"); if (fp != NULL) { errno = 0;
--- a/tests/test-fdatasync.c +++ b/tests/test-fdatasync.c @@ -51,6 +51,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fdatasync (99) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fdopen.c +++ b/tests/test-fdopen.c @@ -42,6 +42,7 @@ { FILE *fp; + close (99); errno = 0; fp = fdopen (99, "r"); if (fp == NULL)
--- a/tests/test-fdopendir.c +++ b/tests/test-fdopendir.c @@ -54,6 +54,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fdopendir (99) == NULL); ASSERT (errno == EBADF);
--- a/tests/test-fflush.c +++ b/tests/test-fflush.c @@ -172,7 +172,9 @@ } } { - FILE *fp = fdopen (99, "w"); + FILE *fp; + close (99); + fp = fdopen (99, "w"); if (fp != NULL) { fputc ('x', fp);
--- a/tests/test-fgetc.c +++ b/tests/test-fgetc.c @@ -77,7 +77,9 @@ } } { - FILE *fp = fdopen (99, "r"); + FILE *fp; + close (99); + fp = fdopen (99, "r"); if (fp != NULL) { errno = 0;
--- a/tests/test-fputc.c +++ b/tests/test-fputc.c @@ -70,7 +70,9 @@ } } { - FILE *fp = fdopen (99, "w"); + FILE *fp; + close (99); + fp = fdopen (99, "w"); if (fp != NULL) { setvbuf (fp, NULL, _IONBF, 0);
--- a/tests/test-fread.c +++ b/tests/test-fread.c @@ -79,7 +79,9 @@ } } { - FILE *fp = fdopen (99, "r"); + FILE *fp; + close (99); + fp = fdopen (99, "r"); if (fp != NULL) { char buf[1];
--- a/tests/test-freopen.c +++ b/tests/test-freopen.c @@ -62,7 +62,9 @@ } } { - FILE *fp = fdopen (99, "w+"); + FILE *fp; + close (99); + fp = fdopen (99, "w+"); if (fp != NULL) { errno = 0;
--- a/tests/test-fseeko4.c +++ b/tests/test-fseeko4.c @@ -57,7 +57,9 @@ } } { - FILE *fp = fdopen (99, "w"); + FILE *fp; + close (99); + fp = fdopen (99, "w"); if (fp != NULL) { errno = 0;
--- a/tests/test-fstat.c +++ b/tests/test-fstat.c @@ -39,6 +39,7 @@ { struct stat statbuf; + close (99); errno = 0; ASSERT (fstat (99, &statbuf) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fstatat.c +++ b/tests/test-fstatat.c @@ -78,6 +78,7 @@ { struct stat statbuf; + close (99); errno = 0; ASSERT (fstatat (99, "foo", &statbuf, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fsync.c +++ b/tests/test-fsync.c @@ -51,6 +51,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (fsync (99) == -1); ASSERT (errno == EBADF);
--- a/tests/test-ftello4.c +++ b/tests/test-ftello4.c @@ -54,7 +54,9 @@ } } { - FILE *fp = fdopen (99, "w"); + FILE *fp; + close (99); + fp = fdopen (99, "w"); if (fp != NULL) { errno = 0;
--- a/tests/test-ftruncate.c +++ b/tests/test-ftruncate.c @@ -38,6 +38,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (ftruncate (99, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-futimens.h +++ b/tests/test-futimens.h @@ -83,6 +83,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (func (99, NULL) == -1); ASSERT (errno == EBADF);
--- a/tests/test-fwrite.c +++ b/tests/test-fwrite.c @@ -72,7 +72,9 @@ } } { - FILE *fp = fdopen (99, "w"); + FILE *fp; + close (99); + fp = fdopen (99, "w"); if (fp != NULL) { char buf[5] = "world";
--- a/tests/test-getpeername.c +++ b/tests/test-getpeername.c @@ -45,6 +45,7 @@ struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); + close (99); errno = 0; ASSERT (getpeername (99, (struct sockaddr *) &addr, &addrlen) == -1); ASSERT (errno == EBADF);
--- a/tests/test-getsockname.c +++ b/tests/test-getsockname.c @@ -45,6 +45,7 @@ struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); + close (99); errno = 0; ASSERT (getsockname (99, (struct sockaddr *) &addr, &addrlen) == -1); ASSERT (errno == EBADF);
--- a/tests/test-getsockopt.c +++ b/tests/test-getsockopt.c @@ -45,6 +45,7 @@ int value; socklen_t value_len = sizeof (value); + close (99); errno = 0; ASSERT (getsockopt (99, SOL_SOCKET, SO_REUSEADDR, &value, &value_len) == -1);
--- a/tests/test-grantpt.c +++ b/tests/test-grantpt.c @@ -48,6 +48,7 @@ { int ret; + close (99); errno = 0; ret = grantpt (99); if (ret != 0)
--- a/tests/test-ioctl.c +++ b/tests/test-ioctl.c @@ -39,6 +39,7 @@ } { int value; + close (99); errno = 0; ASSERT (ioctl (99, FIONREAD, &value) == -1); ASSERT (errno == EBADF);
--- a/tests/test-isatty.c +++ b/tests/test-isatty.c @@ -49,6 +49,7 @@ ); } { + close (99); errno = 0; ASSERT (isatty (99) == 0); ASSERT (errno == EBADF
--- a/tests/test-linkat.c +++ b/tests/test-linkat.c @@ -102,6 +102,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (linkat (99, "foo", AT_FDCWD, "bar", 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-listen.c +++ b/tests/test-listen.c @@ -38,6 +38,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (listen (99 ,1) == -1); ASSERT (errno == EBADF);
--- a/tests/test-lseek.c +++ b/tests/test-lseek.c @@ -95,6 +95,7 @@ ASSERT (lseek (-1, (off_t)0, SEEK_CUR) == -1); ASSERT (errno == EBADF); + close (99); errno = 0; ASSERT (lseek (99, (off_t)0, SEEK_CUR) == -1); ASSERT (errno == EBADF);
--- a/tests/test-mkdirat.c +++ b/tests/test-mkdirat.c @@ -64,6 +64,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (mkdirat (99, "foo", 0700) == -1); ASSERT (errno == EBADF);
--- a/tests/test-mkfifoat.c +++ b/tests/test-mkfifoat.c @@ -98,6 +98,7 @@ ); } { + close (99); errno = 0; ASSERT (func (99, "foo", 0600) == -1); ASSERT (errno == EBADF
--- a/tests/test-openat.c +++ b/tests/test-openat.c @@ -72,6 +72,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (openat (99, "foo", O_RDONLY) == -1); ASSERT (errno == EBADF);
--- a/tests/test-pread.c +++ b/tests/test-pread.c @@ -92,6 +92,7 @@ } { char byte; + close (99); errno = 0; ASSERT (pread (99, &byte, 1, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-pwrite.c +++ b/tests/test-pwrite.c @@ -86,6 +86,7 @@ } { char byte = 'x'; + close (99); errno = 0; ASSERT (pwrite (99, &byte, 1, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-read.c +++ b/tests/test-read.c @@ -60,6 +60,7 @@ } { char byte; + close (99); errno = 0; ASSERT (read (99, &byte, 1) == -1); ASSERT (errno == EBADF);
--- a/tests/test-readlinkat.c +++ b/tests/test-readlinkat.c @@ -66,6 +66,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (readlinkat (99, "foo", buf, sizeof buf) == -1); ASSERT (errno == EBADF);
--- a/tests/test-recv.c +++ b/tests/test-recv.c @@ -40,6 +40,7 @@ } { char byte; + close (99); errno = 0; ASSERT (recv (99, &byte, 1, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-recvfrom.c +++ b/tests/test-recvfrom.c @@ -50,6 +50,7 @@ struct sockaddr_in addr; socklen_t addrlen = sizeof (addr); + close (99); errno = 0; ASSERT (recvfrom (99, &byte, 1, 0, (struct sockaddr *) &addr, &addrlen) == -1);
--- a/tests/test-renameat.c +++ b/tests/test-renameat.c @@ -68,6 +68,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (renameat (99, "foo", AT_FDCWD, "bar") == -1); ASSERT (errno == EBADF);
--- a/tests/test-select.h +++ b/tests/test-select.h @@ -297,6 +297,7 @@ # else fd = 99; # endif + close (fd); if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF) failed ("invalid fd among rfds");
--- a/tests/test-send.c +++ b/tests/test-send.c @@ -40,6 +40,7 @@ } { char byte = 'x'; + close (99); errno = 0; ASSERT (send (99, &byte, 1, 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-sendto.c +++ b/tests/test-sendto.c @@ -52,6 +52,7 @@ } { char byte = 'x'; + close (99); errno = 0; ASSERT (sendto (99, &byte, 1, 0, (const struct sockaddr *) &addr, sizeof (addr))
--- a/tests/test-setsockopt.c +++ b/tests/test-setsockopt.c @@ -43,6 +43,7 @@ { int value = 1; + close (99); errno = 0; ASSERT (setsockopt (99, SOL_SOCKET, SO_REUSEADDR, &value, sizeof (value)) == -1);
--- a/tests/test-shutdown.c +++ b/tests/test-shutdown.c @@ -38,6 +38,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (shutdown (99, SHUT_RD) == -1); ASSERT (errno == EBADF);
--- a/tests/test-symlinkat.c +++ b/tests/test-symlinkat.c @@ -67,6 +67,7 @@ ); } { + close (99); errno = 0; ASSERT (symlinkat ("foo", 99, "bar") == -1); ASSERT (errno == EBADF
--- a/tests/test-ttyname_r.c +++ b/tests/test-ttyname_r.c @@ -55,7 +55,9 @@ ); } { - int err = ttyname_r (99, buf, sizeof (buf)); + int err; + close (99); + err = ttyname_r (99, buf, sizeof (buf)); ASSERT (err == EBADF || err == ENOTTY /* seen on FreeBSD 6.4 */ );
--- a/tests/test-unlinkat.c +++ b/tests/test-unlinkat.c @@ -75,6 +75,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (unlinkat (99, "foo", 0) == -1); ASSERT (errno == EBADF);
--- a/tests/test-unlockpt.c +++ b/tests/test-unlockpt.c @@ -38,6 +38,7 @@ ); } { + close (99); errno = 0; ASSERT (unlockpt (99) == -1); ASSERT (errno == EBADF
--- a/tests/test-utimensat.c +++ b/tests/test-utimensat.c @@ -76,6 +76,7 @@ ASSERT (errno == EBADF); } { + close (99); errno = 0; ASSERT (utimensat (99, "foo", NULL, 0) == -1); ASSERT (errno == EBADF);