Fixed the interaction of --fake-super with --link-dest & --xattrs.
[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
13to2dir="$tmpdir/to2"
14
15chkfile="$scratchdir/rsync.chk"
16outfile="$scratchdir/rsync.out"
17
18makepath "$fromdir/foo"
19makepath "$fromdir/bar/baz"
20cp -p "$srcdir/configure.in" "$fromdir/foo/config1"
21cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
22cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
23chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
24umask 0
25ln -s ../bar/baz/rsync "$fromdir/foo/sym"
26umask 022
27ln "$fromdir/foo/config1" "$fromdir/foo/extra"
28rm -f "$to2dir"
29
30# Check if rsync is set to hard-link symlinks.
31confile=`echo "$scratchdir" | sed 's;/testtmp/itemize$;/config.h;'`
32if egrep '^#define CAN_HARDLINK_SYMLINK 1' "$confile" >/dev/null; then
33 L=hL
34else
35 L=cL
36fi
37
38# Check if rsync can preserve time on symlinks
39case "$RSYNC" in
40*protocol=2*)
41 T=.T
42 ;;
43*)
44 if $RSYNC --version | grep ", symtimes" >/dev/null; then
45 T=.t
46 else
47 T=.T
48 fi
49 ;;
50esac
51
52$RSYNC -iplr "$fromdir/" "$todir/" \
53 | tee "$outfile"
54cat <<EOT >"$chkfile"
55cd$all_plus ./
56cd$all_plus bar/
57cd$all_plus bar/baz/
58>f$all_plus bar/baz/rsync
59cd$all_plus foo/
60>f$all_plus foo/config1
61>f$all_plus foo/config2
62>f$all_plus foo/extra
63cL$all_plus foo/sym -> ../bar/baz/rsync
64EOT
65diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
66
67# Ensure there are no accidental directory-time problems.
68$RSYNC -a -f '-! */' "$fromdir/" "$todir"
69
70cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
71chmod 601 "$fromdir/foo/config2"
72$RSYNC -iplrH "$fromdir/" "$todir/" \
73 | tee "$outfile"
74cat <<EOT >"$chkfile"
75>f..T.$dots bar/baz/rsync
76>f..T.$dots foo/config1
77>f.sTp$dots foo/config2
78hf..T.$dots foo/extra => foo/config1
79EOT
80diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
81
82$RSYNC -a -f '-! */' "$fromdir/" "$todir"
83sleep 1 # For directory mod below to ensure time difference
84rm "$todir/foo/sym"
85umask 0
86ln -s ../bar/baz "$todir/foo/sym"
87umask 022
88cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
89chmod 600 "$fromdir/foo/config2"
90chmod 777 "$todir/bar/baz/rsync"
91
92$RSYNC -iplrtc "$fromdir/" "$todir/" \
93 | tee "$outfile"
94cat <<EOT >"$chkfile"
95.f..tp$dots bar/baz/rsync
96.d..t.$dots foo/
97.f..t.$dots foo/config1
98>fcstp$dots foo/config2
99cL.$T.$dots foo/sym -> ../bar/baz/rsync
100EOT
101diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
102
103cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
104chmod 600 "$fromdir/foo/config2"
105# Lack of -t is for unchanged hard-link stress-test!
106$RSYNC -vvplrH "$fromdir/" "$todir/" \
107 | tee "$outfile"
108filter_outfile
109cat <<EOT >"$chkfile"
110bar/baz/rsync is uptodate
111foo/config1 is uptodate
112foo/config2
113foo/extra is uptodate
114foo/sym is uptodate
115EOT
116diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
117
118chmod 747 "$todir/bar/baz/rsync"
119$RSYNC -a -f '-! */' "$fromdir/" "$todir"
120$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
121 | tee "$outfile"
122filter_outfile
123cat <<EOT >"$chkfile"
124.d$allspace ./
125.d$allspace bar/
126.d$allspace bar/baz/
127.f...p$dots bar/baz/rsync
128.d$allspace foo/
129.f$allspace foo/config1
130>f..t.$dots foo/config2
131hf$allspace foo/extra
132.L$allspace foo/sym -> ../bar/baz/rsync
133EOT
134diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
135
136chmod 757 "$todir/foo/config1"
137touch "$todir/foo/config2"
138$RSYNC -vplrtH "$fromdir/" "$todir/" \
139 | tee "$outfile"
140filter_outfile
141cat <<EOT >"$chkfile"
142foo/config2
143EOT
144diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
145
146chmod 757 "$todir/foo/config1"
147touch "$todir/foo/config2"
148$RSYNC -iplrtH "$fromdir/" "$todir/" \
149 | tee "$outfile"
150cat <<EOT >"$chkfile"
151.f...p$dots foo/config1
152>f..t.$dots foo/config2
153EOT
154diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
155
156$RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
157 | tee "$outfile"
158filter_outfile
159case `tail -1 "$outfile"` in
160cL..t*)
161 sym_dots="..t.$dots"
162 L_sym_dots="cL$sym_dots"
163 is_uptodate='-> ../bar/baz/rsync'
164 echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
165 L=cL
166 ;;
167*)
168 sym_dots="$allspace"
169 L_sym_dots=".L$allspace"
170 is_uptodate='is uptodate'
171 touch "$chkfile.extra"
172 ;;
173esac
174cat <<EOT >"$chkfile"
175cd$allspace ./
176cd$allspace bar/
177cd$allspace bar/baz/
178cf$allspace bar/baz/rsync
179cd$allspace foo/
180cf$allspace foo/config1
181cf$allspace foo/config2
182hf$allspace foo/extra => foo/config1
183cL$sym_dots foo/sym -> ../bar/baz/rsync
184EOT
185diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
186
187rm -rf "$to2dir"
188$RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
189 | tee "$outfile"
190cat - "$chkfile.extra" <<EOT >"$chkfile"
191hf$allspace foo/extra => foo/config1
192EOT
193diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
194
195rm -rf "$to2dir"
196$RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
197 | tee "$outfile"
198filter_outfile
199cat <<EOT >"$chkfile"
200./ is uptodate
201bar/ is uptodate
202bar/baz/ is uptodate
203bar/baz/rsync is uptodate
204foo/ is uptodate
205foo/config1 is uptodate
206foo/config2 is uptodate
207foo/extra => foo/config1
208foo/sym $is_uptodate
209EOT
210diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
211
212rm -rf "$to2dir"
213$RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
214 | tee "$outfile"
215filter_outfile
216cat <<EOT >"$chkfile"
217cd$allspace ./
218cd$allspace bar/
219cd$allspace bar/baz/
220hf$allspace bar/baz/rsync
221cd$allspace foo/
222hf$allspace foo/config1
223hf$allspace foo/config2
224hf$allspace foo/extra => foo/config1
225$L$sym_dots foo/sym -> ../bar/baz/rsync
226EOT
227diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
228
229rm -rf "$to2dir"
230$RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
231 | tee "$outfile"
232cat - "$chkfile.extra" <<EOT >"$chkfile"
233EOT
234diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
235
236rm -rf "$to2dir"
237$RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
238 | tee "$outfile"
239cat - "$chkfile.extra" <<EOT >"$chkfile"
240EOT
241diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
242
243rm -rf "$to2dir"
244$RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
245 | tee "$outfile"
246filter_outfile
247cat <<EOT >"$chkfile"
248./ is uptodate
249bar/ is uptodate
250bar/baz/ is uptodate
251bar/baz/rsync is uptodate
252foo/ is uptodate
253foo/config1 is uptodate
254foo/config2 is uptodate
255foo/extra is uptodate
256foo/sym $is_uptodate
257EOT
258diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
259
260rm -rf "$to2dir"
261$RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
262 | tee "$outfile"
263filter_outfile
264cat <<EOT >"$chkfile"
265cd$allspace ./
266cd$allspace bar/
267cd$allspace bar/baz/
268.f$allspace bar/baz/rsync
269cd$allspace foo/
270.f$allspace foo/config1
271.f$allspace foo/config2
272.f$allspace foo/extra
273$L_sym_dots foo/sym -> ../bar/baz/rsync
274EOT
275diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
276
277rm -rf "$to2dir"
278$RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
279 | tee "$outfile"
280cat - "$chkfile.extra" <<EOT >"$chkfile"
281EOT
282diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
283
284rm -rf "$to2dir"
285$RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
286 | tee "$outfile"
287filter_outfile
288cat <<EOT >"$chkfile"
289./ is uptodate
290bar/ is uptodate
291bar/baz/ is uptodate
292bar/baz/rsync is uptodate
293foo/ is uptodate
294foo/config1 is uptodate
295foo/config2 is uptodate
296foo/extra is uptodate
297foo/sym $is_uptodate
298EOT
299diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
300
301# The script would have aborted on error, so getting here means we've won.
302exit 0