If the OS can't hard-link a symlink, tweak the expected output
[rsync/rsync.git] / testsuite / itemize.test
1 #! /bin/sh
2
3 # Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
4
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
7
8 # Test the output of various copy commands to ensure itemized output
9 # and double-verbose output is correct.
10
11 . "$suitedir/rsync.fns"
12
13 lddir="$tmpdir/ld"
14
15 chkfile="$scratchdir/rsync.chk"
16 outfile="$scratchdir/rsync.out"
17
18 makepath "$fromdir/foo"
19 makepath "$fromdir/bar/baz"
20 cp -p "$srcdir/configure.in" "$fromdir/foo/config1"
21 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
22 cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
23 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
24 umask 0
25 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
26 umask 022
27 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
28
29 # Check if the OS can hard-link symlinks or not
30 ln "$fromdir/foo/sym" "$fromdir/foo/sym.test" && L=hL || L=cL
31 rm -f "$fromdir/foo/sym.test"
32
33 $RSYNC -iplr "$fromdir/" "$todir/" \
34     | tee "$outfile"
35 cat <<EOT >"$chkfile"
36 cd+++++++ ./
37 cd+++++++ bar/
38 cd+++++++ bar/baz/
39 >f+++++++ bar/baz/rsync
40 cd+++++++ foo/
41 >f+++++++ foo/config1
42 >f+++++++ foo/config2
43 >f+++++++ foo/extra
44 cL+++++++ foo/sym -> ../bar/baz/rsync
45 EOT
46 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
47
48 # Ensure there are no accidental directory-time problems.
49 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
50
51 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
52 chmod 601 "$fromdir/foo/config2"
53 $RSYNC -iplrH "$fromdir/" "$todir/" \
54     | tee "$outfile"
55 cat <<EOT >"$chkfile"
56 >f..T.... bar/baz/rsync
57 >f..T.... foo/config1
58 >f.sTp... foo/config2
59 hf..T.... foo/extra => foo/config1
60 EOT
61 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
62
63 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
64 sleep 1 # For directory mod below to ensure time difference
65 rm "$todir/foo/sym"
66 umask 0
67 ln -s ../bar/baz "$todir/foo/sym"
68 umask 022
69 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
70 chmod 600 "$fromdir/foo/config2"
71 chmod 777 "$todir/bar/baz/rsync"
72
73 $RSYNC -iplrtc "$fromdir/" "$todir/" \
74     | tee "$outfile"
75 cat <<EOT >"$chkfile"
76 .f..tp... bar/baz/rsync
77 .d..t.... foo/
78 .f..t.... foo/config1
79 >fcstp... foo/config2
80 cL..T.... foo/sym -> ../bar/baz/rsync
81 EOT
82 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
83
84 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
85 chmod 600 "$fromdir/foo/config2"
86 # Lack of -t is for unchanged hard-link stress-test!
87 $RSYNC -vvplrH "$fromdir/" "$todir/" \
88     | tee "$outfile"
89 filter_outfile
90 cat <<EOT >"$chkfile"
91 bar/baz/rsync is uptodate
92 foo/config1 is uptodate
93 foo/config2
94 "foo/extra" is a hard link
95 foo/sym is uptodate
96 EOT
97 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
98
99 chmod 747 "$todir/bar/baz/rsync"
100 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
101 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
102     | tee "$outfile"
103 filter_outfile
104 cat <<EOT >"$chkfile"
105 .d        ./
106 .d        bar/
107 .d        bar/baz/
108 .f...p... bar/baz/rsync
109 .d        foo/
110 .f        foo/config1
111 >f..t.... foo/config2
112 hf        foo/extra
113 .L        foo/sym -> ../bar/baz/rsync
114 EOT
115 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
116
117 chmod 757 "$todir/foo/config1"
118 touch "$todir/foo/config2"
119 $RSYNC -vplrtH "$fromdir/" "$todir/" \
120     | tee "$outfile"
121 filter_outfile
122 cat <<EOT >"$chkfile"
123 foo/config2
124 EOT
125 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
126
127 chmod 757 "$todir/foo/config1"
128 touch "$todir/foo/config2"
129 $RSYNC -iplrtH "$fromdir/" "$todir/" \
130     | tee "$outfile"
131 cat <<EOT >"$chkfile"
132 .f...p... foo/config1
133 >f..t.... foo/config2
134 EOT
135 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
136
137 mv "$todir" "$lddir"
138 $RSYNC -ivvplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
139     | tee "$outfile"
140 filter_outfile
141 cat <<EOT >"$chkfile"
142 cd        ./
143 cd        bar/
144 cd        bar/baz/
145 cf        bar/baz/rsync
146 cd        foo/
147 cf        foo/config1
148 cf        foo/config2
149 hf        foo/extra => foo/config1
150 cL        foo/sym -> ../bar/baz/rsync
151 EOT
152 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
153
154 rm -rf "$todir"
155 $RSYNC -iplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
156     | tee "$outfile"
157 cat <<EOT >"$chkfile"
158 hf        foo/extra => foo/config1
159 EOT
160 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
161
162 rm -rf "$todir"
163 $RSYNC -vvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
164     | tee "$outfile"
165 filter_outfile
166 cat <<EOT >"$chkfile"
167 ./ is uptodate
168 bar/ is uptodate
169 bar/baz/ is uptodate
170 bar/baz/rsync is uptodate
171 foo/ is uptodate
172 foo/config1 is uptodate
173 foo/config2 is uptodate
174 "foo/extra" is a hard link
175 foo/extra => foo/config1
176 foo/sym is uptodate
177 EOT
178 diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
179
180 rm -rf "$todir"
181 $RSYNC -ivvplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
182     | tee "$outfile"
183 filter_outfile
184 cat <<EOT >"$chkfile"
185 cd        ./
186 cd        bar/
187 cd        bar/baz/
188 hf        bar/baz/rsync
189 cd        foo/
190 hf        foo/config1
191 hf        foo/config2
192 hf        foo/extra => foo/config1
193 $L        foo/sym -> ../bar/baz/rsync
194 EOT
195 diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
196
197 rm -rf "$todir"
198 $RSYNC -iplrtH --dry-run --link-dest=../ld "$fromdir/" "$todir/" \
199     | tee "$outfile"
200 cat <<EOT >"$chkfile"
201 EOT
202 diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
203
204 rm -rf "$todir"
205 $RSYNC -iplrtH --link-dest=../ld "$fromdir/" "$todir/" \
206     | tee "$outfile"
207 cat <<EOT >"$chkfile"
208 EOT
209 diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
210
211 rm -rf "$todir"
212 $RSYNC -vvplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
213     | tee "$outfile"
214 filter_outfile
215 cat <<EOT >"$chkfile"
216 ./ is uptodate
217 bar/ is uptodate
218 bar/baz/ is uptodate
219 bar/baz/rsync is uptodate
220 foo/ is uptodate
221 foo/config1 is uptodate
222 foo/config2 is uptodate
223 "foo/extra" is a hard link
224 foo/sym is uptodate
225 EOT
226 diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
227
228 rm -rf "$todir"
229 $RSYNC -ivvplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
230     | tee "$outfile"
231 filter_outfile
232 # TODO fix really-old problem when combining -H with --compare-dest:
233 # missing output for foo/extra hard-link (and it might not be updated)!
234 cat <<EOT >"$chkfile"
235 cd        ./
236 cd        bar/
237 cd        bar/baz/
238 .f        bar/baz/rsync
239 cd        foo/
240 .f        foo/config1
241 .f        foo/config2
242 .L        foo/sym -> ../bar/baz/rsync
243 EOT
244 diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
245
246 rm -rf "$todir"
247 $RSYNC -iplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
248     | tee "$outfile"
249 cat <<EOT >"$chkfile"
250 EOT
251 diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
252
253 rm -rf "$todir"
254 $RSYNC -vvplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
255     | tee "$outfile"
256 filter_outfile
257 cat <<EOT >"$chkfile"
258 ./ is uptodate
259 bar/ is uptodate
260 bar/baz/ is uptodate
261 bar/baz/rsync is uptodate
262 foo/ is uptodate
263 foo/config1 is uptodate
264 foo/config2 is uptodate
265 "foo/extra" is a hard link
266 foo/sym is uptodate
267 EOT
268 diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
269
270 # The script would have aborted on error, so getting here means we've won.
271 exit 0