New module attribute 'Applicability'.
[gnulib.git] / tests / test-link.c
index 250a821..dd7df2e 100644 (file)
 #include <unistd.h>
 
 #include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #define ASSERT(expr) \
   do                                                                         \
     }                                                                        \
   while (0)
 
+#define BASE "test-link.t"
+
+#include "test-link.h"
+
 int
-main (int argc, char **argv)
+main (void)
 {
-  int ret;
-
-  ASSERT (argc == 3);
-
-  ret = link (argv[1], argv[2]);
-  if (ret < 0)
-    {
-      /* If the device does not support hard links, errno is
-        EPERM on Linux, EOPNOTSUPP on FreeBSD.  */
-      switch (errno)
-       {
-       case EPERM:
-#ifdef EOPNOTSUPP
-       case EOPNOTSUPP:
-#endif
-         return 77;
-       default:
-         perror ("link");
-         return 1;
-       }
-    }
-
-  return 0;
+  /* Remove any garbage left from previous partial runs.  */
+  ASSERT (system ("rm -rf " BASE "*") == 0);
+
+  return test_link (link, true);
 }