Mercurial > hg > octave-kai > gnulib-hg
changeset 15703:97b70675b25e
linkat tests: EBADF tests.
* tests/test-linkat.c (main): Add tests for EBADF.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 20 Sep 2011 22:43:43 +0200 |
parents | e52fd8710d18 |
children | 17eaeb48cbef |
files | ChangeLog tests/test-linkat.c |
diffstat | 2 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-09-20 Bruno Haible <bruno@clisp.org> + linkat tests: EBADF tests. + * tests/test-linkat.c (main): Add tests for EBADF. + Tests for module 'faccessat'. * modules/faccessat-tests: New file. * tests/test-faccessat.c: New file.
--- a/tests/test-linkat.c +++ b/tests/test-linkat.c @@ -95,6 +95,29 @@ /* Clean up any trash from prior testsuite runs. */ ignore_value (system ("rm -rf " BASE "*")); + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (linkat (-1, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (linkat (99, "foo", AT_FDCWD, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + ASSERT (close (creat (BASE "oo", 0600)) == 0); + { + errno = 0; + ASSERT (linkat (AT_FDCWD, BASE "oo", -1, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (linkat (AT_FDCWD, BASE "oo", 99, "bar", 0) == -1); + ASSERT (errno == EBADF); + } + /* Test basic link functionality, without mentioning symlinks. */ result = test_link (do_link, true); dfd1 = open (".", O_RDONLY);