From c3debac110729b6479bdae9f3e744c9055483c4d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 20 Jan 2009 01:21:30 +0100 Subject: [PATCH] Skip test when a hard link cannot be created. --- ChangeLog | 9 +++++++++ tests/test-link.c | 15 ++++++++++++++- tests/test-link.sh | 11 ++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b2a59dda6..f77389c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-01-19 Bruno Haible + + * tests/test-link.c: Include . + (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 * modules/link-tests: New file. diff --git a/tests/test-link.c b/tests/test-link.c index 255a939e6..a35892113 100644 --- a/tests/test-link.c +++ b/tests/test-link.c @@ -18,6 +18,7 @@ #include +#include #include #include @@ -36,8 +37,20 @@ 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; } diff --git a/tests/test-link.sh b/tests/test-link.sh index e18bb63fc..1519f9d9a 100755 --- a/tests/test-link.sh +++ b/tests/test-link.sh @@ -7,7 +7,16 @@ trap 'rm -fr $tmpfiles' 1 2 3 15 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. -- 2.11.0