e18bb63fce348e6dcf17070c77cd4998561bb2af
[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 || exit 1
11 cmp test-link-a.txt test-link-b.txt || exit 1
12
13 # Modify the contents of the first file.
14 echo "world" >> test-link-a.txt || exit 1
15 cmp test-link-a.txt test-link-b.txt || exit 1
16
17 # Modify the contents of the second file.
18 echo "some text" >> test-link-b.txt || exit 1
19 cmp test-link-a.txt test-link-b.txt || exit 1
20
21 # Delete the first file, then verity the second file still has the same
22 # contents.
23 cp test-link-a.txt test-link-c.txt || exit 1
24 rm test-link-a.txt || exit 1
25 cmp test-link-b.txt test-link-c.txt || exit 1
26
27 rm -fr $tmpfiles
28 exit 0