doc: use ASCII in .texi files where UTF-8 isn't needed
[gnulib.git] / tests / test-file-has-acl.c
index daab4db..f0de2ce 100644 (file)
@@ -1,5 +1,5 @@
 /* Test for presence of ACL.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-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 "acl.h"
 
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#define ASSERT(expr) \
-  do                                                                        \
-    {                                                                       \
-      if (!(expr))                                                          \
-        {                                                                   \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);                                                  \
-          abort ();                                                         \
-        }                                                                   \
-    }                                                                       \
-  while (0)
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
@@ -54,13 +45,24 @@ main (int argc, char *argv[])
       exit (EXIT_FAILURE);
     }
 
+  /* Check against possible infinite loop in file_has_acl.  */
+#if HAVE_DECL_ALARM
+  /* Declare failure if test takes too long, by using default abort
+     caused by SIGALRM.  */
+  {
+    int alarm_value = 5;
+    signal (SIGALRM, SIG_DFL);
+    alarm (alarm_value);
+  }
+#endif
+
 #if USE_ACL
   {
     int ret = file_has_acl (file, &statbuf);
     if (ret < 0)
       {
-       fprintf (stderr, "could not access the ACL of file \"%s\"\n", file);
-       exit (EXIT_FAILURE);
+        fprintf (stderr, "could not access the ACL of file \"%s\"\n", file);
+        exit (EXIT_FAILURE);
       }
     printf ("%s\n", ret ? "yes" : "no");
   }