New module attribute 'Applicability'.
[gnulib.git] / tests / test-fopen.h
index 01369f8..6ba923b 100644 (file)
 #include <unistd.h>
 
 #define ASSERT(expr) \
-  do                                                                        \
-    {                                                                       \
-      if (!(expr))                                                          \
-        {                                                                   \
+  do                                                                         \
+    {                                                                        \
+      if (!(expr))                                                           \
+        {                                                                    \
           fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);                                                  \
-          abort ();                                                         \
-        }                                                                   \
-    }                                                                       \
+          fflush (stderr);                                                   \
+          abort ();                                                          \
+        }                                                                    \
+    }                                                                        \
   while (0)
 
 /* Test fopen.  Assumes BASE is defined.  */
@@ -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");