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