maint: update copyright
[gnulib.git] / tests / test-fopen.h
index 01369f8..f87bb2e 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of opening a file stream.
-   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+   Copyright (C) 2007-2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 /* Include <config.h> and a form of <stdio.h> first.  */
 
 #include <errno.h>
-#include <stdlib.h>
 #include <unistd.h>
 
-#define ASSERT(expr) \
-  do                                                                        \
-    {                                                                       \
-      if (!(expr))                                                          \
-        {                                                                   \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);                                                  \
-          abort ();                                                         \
-        }                                                                   \
-    }                                                                       \
-  while (0)
+#include "macros.h"
 
 /* Test fopen.  Assumes BASE is defined.  */
 
@@ -56,17 +45,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");