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