New module attribute 'Applicability'.
[gnulib.git] / tests / test-fdopendir.c
index 003a279..7e0b3ee 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)
 
 int
-main ()
+main (void)
 {
   DIR *d;
   int fd;
 
   /* A non-directory cannot be turned into a directory stream.  */
-  fd = open ("/dev/null", O_RDONLY);
+  fd = open ("test-fdopendir.tmp", O_RDONLY | O_CREAT, 0600);
   ASSERT (0 <= fd);
   errno = 0;
   ASSERT (fdopendir (fd) == NULL);
   ASSERT (errno == ENOTDIR);
   ASSERT (close (fd) == 0);
+  ASSERT (unlink ("test-fdopendir.tmp") == 0);
 
   /* A bad fd cannot be turned into a stream.  */
   errno = 0;