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 # Compare regular file with regular file.
17 returns_
1 diff --no-dereference regular1 regular2
> out || fail
=1
18 cat <<EOF > expected || framework_failure_
24 compare expected out || fail
=1
26 # Compare regular file with symbolic link.
27 returns_
1 diff --no-dereference regular1 symlink1
> out || fail
=1
28 cat <<EOF > expected || framework_failure_
29 File regular1 is a regular file while file symlink1 is a symbolic link
31 compare expected out || fail
=1
33 # Compare symbolic link with regular file.
34 returns_
1 diff --no-dereference symlink1 regular1
> out || fail
=1
35 cat <<EOF > expected || framework_failure_
36 File symlink1 is a symbolic link while file regular1 is a regular file
38 compare expected out || fail
=1
40 # Compare symbolic links with same value.
41 diff --no-dereference symlink1 symlink1bis
> out || fail
=1
42 compare
/dev
/null out || fail
=1
44 # Compare symbolic links with different value and different target contents.
45 LC_ALL
=C returns_
1 diff --no-dereference symlink1 symlink2
> out || fail
=1
46 cat <<EOF > expected || framework_failure_
47 Symbolic links 'symlink1' -> 'regular1' and 'symlink2' -> 'regular2' differ
49 compare expected out || fail
=1
51 # Compare symbolic links with different value and same target contents.
52 LC_ALL
=C returns_
1 diff --no-dereference symlink2 symlink3
> out || fail
=1
53 cat <<EOF > expected || framework_failure_
54 Symbolic links 'symlink2' -> 'regular2' and 'symlink3' -> 'regular3' differ
56 compare expected out || fail
=1
60 ln -s loop subdir
/loop || framework_failure_
61 diff --no-dereference loop subdir
> out || fail
=1
62 compare
/dev
/null out || fail
=1
64 # Recursive comparisons.
66 # Compare symbolic link with nonexistent file.
69 ln -s nonexistent subdir1a
/foo
70 ln -s ..
/regular1 subdir1a
/bar
71 returns_
1 diff -r --no-dereference subdir1a subdir1b
> out || fail
=1
72 cat <<EOF > expected || framework_failure_
76 compare expected out || fail
=1
78 # Compare nonexistent file with symbolic link.
81 ln -s nonexistent subdir2b
/foo
82 ln -s ..
/regular1 subdir2b
/bar
83 returns_
1 diff -r --no-dereference subdir2a subdir2b
> out || fail
=1
84 cat <<EOF > expected || framework_failure_
88 compare expected out || fail
=1
90 # Compare regular file with regular file.
93 cp regular1 subdir3a
/foo
94 cp regular2 subdir3b
/foo
95 returns_
1 diff -r --no-dereference subdir3a subdir3b
> out || fail
=1
96 cat <<EOF > expected || framework_failure_
97 diff -r --no-dereference subdir3a/foo subdir3b/foo
103 compare expected out || fail
=1
105 # Compare regular file with symbolic link.
108 cp regular1 subdir4a
/foo
109 ln -s ..
/regular1 subdir4b
/foo
110 returns_
1 diff -r --no-dereference subdir4a subdir4b
> out || fail
=1
111 cat <<EOF > expected || framework_failure_
112 File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
114 compare expected out || fail
=1
116 # Compare symbolic link with regular file.
119 ln -s ..
/regular1 subdir5a
/foo
120 cp regular1 subdir5b
/foo
121 returns_
1 diff -r --no-dereference subdir5a subdir5b
> out || fail
=1
122 cat <<EOF > expected || framework_failure_
123 File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
125 compare expected out || fail
=1
127 # Compare symbolic links with same value.
130 ln -s ..
/regular1 subdir6a
/foo
131 ln -s ..
/regular1 subdir6b
/foo
132 diff -r --no-dereference subdir6a subdir6b
> out || fail
=1
133 compare
/dev
/null out || fail
=1
135 # Compare symbolic links with different value and different target contents.
138 ln -s ..
/regular1 subdir7a
/foo
139 ln -s ..
/regular2 subdir7b
/foo
140 LC_ALL
=C returns_
1 diff -r --no-dereference subdir7a subdir7b
> out || fail
=1
141 cat <<EOF > expected || framework_failure_
142 Symbolic links 'subdir7a/foo' -> '../regular1' and 'subdir7b/foo' -> '../regular2' differ
144 compare expected out || fail
=1
146 # Compare symbolic links with different value and same target contents.
149 ln -s ..
/regular2 subdir8a
/foo
150 ln -s ..
/regular3 subdir8b
/foo
151 LC_ALL
=C returns_
1 diff -r --no-dereference subdir8a subdir8b
> out || fail
=1
152 cat <<EOF > expected || framework_failure_
153 Symbolic links 'subdir8a/foo' -> '../regular2' and 'subdir8b/foo' -> '../regular3' differ
155 compare expected out || fail
=1