Mercurial > hg > octave-kai > gnulib-hg
changeset 15688:0a93aea8485c
fdatasync tests: EBADF tests.
* tests/test-fdatasync.c (main): Add more tests for EBADF.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 20 Sep 2011 22:03:35 +0200 |
parents | 213bdf475128 |
children | 5f984aab7803 |
files | ChangeLog tests/test-fdatasync.c |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-09-20 Bruno Haible <bruno@clisp.org> + 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.
--- a/tests/test-fdatasync.c +++ b/tests/test-fdatasync.c @@ -32,18 +32,29 @@ 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);