Tests for module 'unicase/u32-casefold'.
[gnulib.git] / tests / test-link.sh
1 #!/bin/sh
2
3 tmpfiles="test-link-a.txt test-link-b.txt test-link-c.txt"
4 trap 'rm -fr $tmpfiles' 1 2 3 15
5
6 # Create a file.
7 echo "hello" > test-link-a.txt || exit 1
8
9 # Use link() to create a new name for it.
10 ./test-link${EXEEXT} test-link-a.txt test-link-b.txt
11 case $? in
12   0) ;;
13   77)
14     echo "Skipping test: hard links are not supported on this file system"
15     rm -fr $tmpfiles
16     exit 77
17     ;;
18   *) exit 1 ;;
19 esac
20 cmp test-link-a.txt test-link-b.txt || exit 1
21
22 # Modify the contents of the first file.
23 echo "world" >> test-link-a.txt || exit 1
24 cmp test-link-a.txt test-link-b.txt || exit 1
25
26 # Modify the contents of the second file.
27 echo "some text" >> test-link-b.txt || exit 1
28 cmp test-link-a.txt test-link-b.txt || exit 1
29
30 # Delete the first file, then verity the second file still has the same
31 # contents.
32 cp test-link-a.txt test-link-c.txt || exit 1
33 rm test-link-a.txt || exit 1
34 cmp test-link-b.txt test-link-c.txt || exit 1
35
36 rm -fr $tmpfiles
37 exit 0