+2009-01-19 Bruno Haible <bruno@clisp.org>
+
+ * tests/test-link.c: Include <errno.h>.
+ (main): Exit with code 77 when a hard link cannot be created due to
+ the file system.
+ * tests/test-link.sh: Skip test when a hard link cannot be created due
+ to the file system.
+ Suggested by Eric Blake.
+
2009-01-19 Martin Lambers <marlam@marlam.de>
* modules/link-tests: New file.
#include <unistd.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char **argv)
{
+ int ret;
+
ASSERT (argc == 3);
- ASSERT (link (argv[1], argv[2]) == 0);
+
+ 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. */
+ if (errno == EPERM || errno == EOPNOTSUPP)
+ return 77;
+ perror ("link");
+ return 1;
+ }
return 0;
}
echo "hello" > test-link-a.txt || exit 1
# Use link() to create a new name for it.
-./test-link${EXEEXT} test-link-a.txt test-link-b.txt || exit 1
+./test-link${EXEEXT} test-link-a.txt test-link-b.txt
+case $? in
+ 0) ;;
+ 77)
+ echo "Skipping test: hard links are not supported on this file system"
+ rm -fr $tmpfiles
+ exit 77
+ ;;
+ *) exit 1 ;;
+esac
cmp test-link-a.txt test-link-b.txt || exit 1
# Modify the contents of the first file.