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