From: Bruno Haible Date: Tue, 20 Sep 2011 20:03:35 +0000 (+0200) Subject: fdatasync tests: EBADF tests. X-Git-Tag: v0.1~1838 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=a49c8a67948d78d10f7e8e73c861e606e7d1cc4b;p=gnulib.git fdatasync tests: EBADF tests. * tests/test-fdatasync.c (main): Add more tests for EBADF. --- diff --git a/ChangeLog b/ChangeLog index 06a2fb21b..d1bf875ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-09-20 Bruno Haible + fdatasync tests: EBADF tests. + * tests/test-fdatasync.c (main): Add more tests for EBADF. + Tests for module 'fchown'. * modules/fchown-tests: New file. * tests/test-fchown.c: New file. diff --git a/tests/test-fdatasync.c b/tests/test-fdatasync.c index d35096dec..a394a4c66 100644 --- a/tests/test-fdatasync.c +++ b/tests/test-fdatasync.c @@ -32,18 +32,29 @@ main (void) int fd; const char *file = "test-fdatasync.txt"; + /* Assuming stdin and stdout are ttys, fdatasync is allowed to fail, but + may succeed as an extension. */ for (fd = 0; fd < 2; fd++) if (fdatasync (fd) != 0) { ASSERT (errno == EINVAL /* POSIX */ || errno == ENOTSUP /* seen on MacOS X 10.5 */ || errno == EBADF /* seen on AIX 7.1 */ + || errno == EIO /* seen on mingw */ ); } - errno = 0; - ASSERT (fdatasync (-1) == -1); - ASSERT (errno == EBADF); + /* fdatasync must fail on invalid fd. */ + { + errno = 0; + ASSERT (fdatasync (-1) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (fdatasync (99) == -1); + ASSERT (errno == EBADF); + } fd = open (file, O_WRONLY|O_CREAT|O_TRUNC, 0644); ASSERT (0 <= fd);