test-open: support mingw errno values
authorEric Blake <ebb9@byu.net>
Sat, 3 Oct 2009 04:40:01 +0000 (22:40 -0600)
committerEric Blake <ebb9@byu.net>
Sat, 3 Oct 2009 04:47:35 +0000 (22:47 -0600)
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>
ChangeLog
tests/test-fopen.h
tests/test-open.h
tests/test-openat-safer.c

index df080c8..547a2a7 100644 (file)
--- 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.
 
index 01369f8..1920b27 100644 (file)
@@ -56,17 +56,18 @@ test_fopen (void)
   /* 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");
index 7381037..4dba767 100644 (file)
@@ -47,7 +47,8 @@ test_open (void)
   /* 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 @@ test_open (void)
   /* 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);
index 7e44d67..221a880 100644 (file)
@@ -101,10 +101,11 @@ main ()
          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);