Mercurial > hg > octave-lojdl > gnulib-hg
changeset 11955:403b7eb1cb88
test-openat-safer: add more checks
* tests/test-openat-safer.c (main): Check more code paths.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Sat, 05 Sep 2009 06:39:17 -0600 |
parents | c2aabb82023d |
children | 55cb5282dd84 |
files | ChangeLog tests/test-openat-safer.c |
diffstat | 2 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-09-05 Eric Blake <ebb9@byu.net> + + test-openat-safer: add more checks + * tests/test-openat-safer.c (main): Check more code paths. + 2009-09-05 Jim Meyering <meyering@redhat.com> syntax-check: detect unnecessary inclusion of openat.h
--- a/tests/test-openat-safer.c +++ b/tests/test-openat-safer.c @@ -92,6 +92,9 @@ errno = 0; ASSERT (openat (dfd, "", O_RDONLY) == -1); ASSERT (errno == ENOENT); + errno = 0; + ASSERT (openat (-1, ".", O_RDONLY) == -1); + ASSERT (errno == EBADF); /* Check for trailing slash and /dev/null handling; the particular errno might be ambiguous. */ @@ -102,8 +105,13 @@ errno = 0; ASSERT (openat (dfd, "/dev/null/", O_RDONLY) == -1); /* ASSERT (errno == ENOTDIR); */ - fd = openat (dfd, "/dev/null", O_RDONLY); + /* Using a bad directory is okay for absolute paths. */ + fd = openat (-1, "/dev/null", O_WRONLY); ASSERT (STDERR_FILENO < fd); + /* Using a non-directory is wrong for relative paths. */ + errno = 0; + ASSERT (openat (fd, ".", O_RDONLY) == -1); + ASSERT (errno == EBADF || errno == ENOTDIR); ASSERT (close (fd) == 0); /* Check for our witness file. */