diff options
author | Bruno Haible <bruno@clisp.org> | 2011-09-20 21:58:23 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2011-09-20 21:58:23 +0200 |
commit | 7fd36dc1852f42a56f1aaa28772b246d4e728249 (patch) | |
tree | b28661811e6534ba3266b766f6fc466ab1834f8f /tests/test-fchdir.c | |
parent | 6e5be7aa24ae8aa7a51afb57b5c99813cab1e1c4 (diff) | |
download | gnulib-7fd36dc1852f42a56f1aaa28772b246d4e728249.tar.gz |
fchdir tests: EBADF tests.
* tests/test-fchdir.c (main): Add more tests for EBADF.
Diffstat (limited to 'tests/test-fchdir.c')
-rw-r--r-- | tests/test-fchdir.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/test-fchdir.c b/tests/test-fchdir.c index 0375c317d8..2e6b06760f 100644 --- a/tests/test-fchdir.c +++ b/tests/test-fchdir.c @@ -34,14 +34,29 @@ SIGNATURE_CHECK (fchdir, int, (int)); int main (void) { - char *cwd = getcwd (NULL, 0); - int fd = open (".", O_RDONLY); + char *cwd; + int fd; int i; + cwd = getcwd (NULL, 0); ASSERT (cwd); + + fd = open (".", O_RDONLY); ASSERT (0 <= fd); - /* Check for failure cases. */ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (fchdir (-1) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (fchdir (99) == -1); + ASSERT (errno == EBADF); + } + + /* Check for other failure cases. */ { int bad_fd = open ("/dev/null", O_RDONLY); ASSERT (0 <= bad_fd); @@ -49,9 +64,6 @@ main (void) ASSERT (fchdir (bad_fd) == -1); ASSERT (errno == ENOTDIR); ASSERT (close (bad_fd) == 0); - errno = 0; - ASSERT (fchdir (-1) == -1); - ASSERT (errno == EBADF); } /* Repeat test twice, once in '.' and once in '..'. */ |