Mercurial > hg > octave-lyh > gnulib-hg
changeset 11056:7a0a9b657190
Skip test when a hard link cannot be created.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Tue, 20 Jan 2009 01:21:30 +0100 |
parents | b1edf9425165 |
children | aa06a0b2d194 |
files | ChangeLog tests/test-link.c tests/test-link.sh |
diffstat | 3 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +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.
--- a/tests/test-link.c +++ b/tests/test-link.c @@ -18,6 +18,7 @@ #include <unistd.h> +#include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -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; }
--- a/tests/test-link.sh +++ b/tests/test-link.sh @@ -7,7 +7,16 @@ 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.