Mercurial > hg > octave-lyh > gnulib-hg
changeset 12107:90198e1c7821
test-open: support mingw errno values
mingw has non-standard errno values for handling directory opens,
but they weren't worth working around in the gnulib modules.
* tests/test-open.h (test_open): Relax test.
* tests/test-fopen.h (test_fopen): Likewise.
* tests/test-openat-safer.c (main): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Fri, 02 Oct 2009 22:40:01 -0600 |
parents | 5f350c5819bd |
children | fd6226a4117b |
files | ChangeLog tests/test-fopen.h tests/test-open.h tests/test-openat-safer.c |
diffstat | 4 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-10-02 Eric Blake <ebb9@byu.net> + test-open: support mingw errno values + * tests/test-open.h (test_open): Relax test. + * tests/test-fopen.h (test_fopen): Likewise. + * tests/test-openat-safer.c (main): Likewise. + open: fix opening directory on mingw * lib/open.c (open) [REPLACE_OPEN_DIRECTORY]: Correct typo.
--- a/tests/test-fopen.h +++ b/tests/test-fopen.h @@ -56,17 +56,18 @@ /* Trailing slash is invalid on non-directory. */ errno = 0; ASSERT (fopen (BASE "file/", "r") == NULL); - ASSERT (errno == ENOTDIR || errno == EISDIR); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); /* Cannot create a directory. */ errno = 0; ASSERT (fopen ("nonexist.ent/", "w") == NULL); - ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); /* Directories cannot be opened for writing. */ errno = 0; ASSERT (fopen (".", "w") == NULL); - ASSERT (errno == EISDIR || errno == EINVAL); + ASSERT (errno == EISDIR || errno == EINVAL || errno == EACCES); /* /dev/null must exist, and be writable. */ f = fopen ("/dev/null", "r");
--- a/tests/test-open.h +++ b/tests/test-open.h @@ -47,7 +47,8 @@ /* Cannot create directory. */ errno = 0; ASSERT (open ("nonexist.ent/", O_CREAT | O_RDONLY, 0600) == -1); - ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); /* Create a regular file. */ fd = open (BASE "file", O_CREAT | O_RDONLY, 0600); @@ -57,12 +58,12 @@ /* Trailing slash handling. */ errno = 0; ASSERT (open (BASE "file/", O_RDONLY) == -1); - ASSERT (errno == ENOTDIR || errno == EISDIR); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); /* Directories cannot be opened for writing. */ errno = 0; ASSERT (open (".", O_WRONLY) == -1); - ASSERT (errno == EISDIR); + ASSERT (errno == EISDIR || errno == EACCES); /* /dev/null must exist, and be writable. */ fd = open ("/dev/null", O_RDONLY);
--- a/tests/test-openat-safer.c +++ b/tests/test-openat-safer.c @@ -101,10 +101,11 @@ errno = 0; ASSERT (openat (dfd, "nonexist.ent/", O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR) == -1); - ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == ENOENT + || errno == EINVAL); errno = 0; ASSERT (openat (dfd, witness "/", O_RDONLY) == -1); - ASSERT (errno == ENOTDIR || errno == EISDIR); + ASSERT (errno == ENOTDIR || errno == EISDIR || errno == EINVAL); /* Using a bad directory is okay for absolute paths. */ fd = openat (-1, "/dev/null", O_WRONLY); ASSERT (STDERR_FILENO < fd);