2 # Test the --no-dereference option.
4 . "${srcdir=.}/init.sh"; path_prepend_ ../src
6 echo 'Simple contents' > regular1
7 echo 'Sample contents' > regular2
8 echo 'Sample contents' > regular3
9 ln -s regular1 symlink1
10 ln -s regular1 symlink1bis
11 ln -s regular2 symlink2
12 ln -s regular3 symlink3
14 # Non-recursive comparisons.
16 # Test case 3: Compare regular file with regular file.
17 diff --no-dereference regular1 regular2 > out
19 cat <<EOF > expected || framework_failure_
25 compare expected out || fail=1
27 # Test case 4: Compare regular file with symbolic link.
28 diff --no-dereference regular1 symlink1 > out
30 cat <<EOF > expected || framework_failure_
31 File regular1 is a regular file while file symlink1 is a symbolic link
33 compare expected out || fail=1
35 # Test case 5: Compare symbolic link with regular file.
36 diff --no-dereference symlink1 regular1 > out
38 cat <<EOF > expected || framework_failure_
39 File symlink1 is a symbolic link while file regular1 is a regular file
41 compare expected out || fail=1
43 # Test case 6: Compare symbolic links with same value.
44 diff --no-dereference symlink1 symlink1bis > out
46 compare /dev/null out || fail=1
48 # Test case 7: Compare symbolic links with different value and different target
50 diff --no-dereference symlink1 symlink2 > out
52 cat <<EOF > expected || framework_failure_
53 Symbolic links symlink1 and symlink2 differ
55 compare expected out || fail=1
57 # Test case 8: Compare symbolic links with different value and same target
59 diff --no-dereference symlink2 symlink3 > out
61 cat <<EOF > expected || framework_failure_
62 Symbolic links symlink2 and symlink3 differ
64 compare expected out || fail=1
66 # Recursive comparisons.
68 # Test case 1: Compare symbolic link with nonexistent file.
71 ln -s nonexistent subdir1a/foo
72 ln -s ../regular1 subdir1a/bar
73 diff -r --no-dereference subdir1a subdir1b > out
75 cat <<EOF > expected || framework_failure_
79 compare expected out || fail=1
81 # Test case 1: Compare nonexistent file with symbolic link.
84 ln -s nonexistent subdir2b/foo
85 ln -s ../regular1 subdir2b/bar
86 diff -r --no-dereference subdir2a subdir2b > out
88 cat <<EOF > expected || framework_failure_
92 compare expected out || fail=1
94 # Test case 3: Compare regular file with regular file.
97 cp regular1 subdir3a/foo
98 cp regular2 subdir3b/foo
99 diff -r --no-dereference subdir3a subdir3b > out
100 test $? = 1 || fail=1
101 cat <<EOF > expected || framework_failure_
102 diff -r --no-dereference subdir3a/foo subdir3b/foo
108 compare expected out || fail=1
110 # Test case 4: Compare regular file with symbolic link.
113 cp regular1 subdir4a/foo
114 ln -s ../regular1 subdir4b/foo
115 diff -r --no-dereference subdir4a subdir4b > out
116 test $? = 1 || fail=1
117 cat <<EOF > expected || framework_failure_
118 File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
120 compare expected out || fail=1
122 # Test case 5: Compare symbolic link with regular file.
125 ln -s ../regular1 subdir5a/foo
126 cp regular1 subdir5b/foo
127 diff -r --no-dereference subdir5a subdir5b > out
128 test $? = 1 || fail=1
129 cat <<EOF > expected || framework_failure_
130 File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
132 compare expected out || fail=1
134 # Test case 6: Compare symbolic links with same value.
137 ln -s ../regular1 subdir6a/foo
138 ln -s ../regular1 subdir6b/foo
139 diff -r --no-dereference subdir6a subdir6b > out
140 test $? = 0 || fail=1
141 compare /dev/null out || fail=1
143 # Test case 7: Compare symbolic links with different value and different target
147 ln -s ../regular1 subdir7a/foo
148 ln -s ../regular2 subdir7b/foo
149 diff -r --no-dereference subdir7a subdir7b > out
150 test $? = 1 || fail=1
151 cat <<EOF > expected || framework_failure_
152 Symbolic links subdir7a/foo and subdir7b/foo differ
154 compare expected out || fail=1
156 # Test case 8: Compare symbolic links with different value and same target
160 ln -s ../regular2 subdir8a/foo
161 ln -s ../regular3 subdir8b/foo
162 diff -r --no-dereference subdir8a subdir8b > out
163 test $? = 1 || fail=1
164 cat <<EOF > expected || framework_failure_
165 Symbolic links subdir8a/foo and subdir8b/foo differ
167 compare expected out || fail=1