Fixed some itemized logging failures:
[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
989b0b88 13to2dir="$tmpdir/to2"
5794112a 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 27ln "$fromdir/foo/config1" "$fromdir/foo/extra"
89b47d43 28rm -f "$to2dir"
5794112a 29
89b47d43
WD
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
3aeedbfd
WD
33 L=hL
34else
35 L=cL
36fi
1ed56a05
WD
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
3b8ed842 51
5794112a
WD
52$RSYNC -iplr "$fromdir/" "$todir/" \
53 | tee "$outfile"
9b9d5f89 54cat <<EOT >"$chkfile"
fc29efc3
WD
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
5794112a 64EOT
4f3be36e 65diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
5794112a
WD
66
67# Ensure there are no accidental directory-time problems.
68$RSYNC -a -f '-! */' "$fromdir/" "$todir"
69
309a5be8 70cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
e73ad2be 71chmod 601 "$fromdir/foo/config2"
5794112a
WD
72$RSYNC -iplrH "$fromdir/" "$todir/" \
73 | tee "$outfile"
9b9d5f89 74cat <<EOT >"$chkfile"
fc29efc3
WD
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
5794112a 79EOT
4f3be36e 80diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
5794112a
WD
81
82$RSYNC -a -f '-! */' "$fromdir/" "$todir"
83sleep 1 # For directory mod below to ensure time difference
84rm "$todir/foo/sym"
a3dcb790 85umask 0
5794112a 86ln -s ../bar/baz "$todir/foo/sym"
a3dcb790 87umask 022
5794112a 88cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
e73ad2be 89chmod 600 "$fromdir/foo/config2"
5794112a
WD
90chmod 777 "$todir/bar/baz/rsync"
91
92$RSYNC -iplrtc "$fromdir/" "$todir/" \
93 | tee "$outfile"
9b9d5f89 94cat <<EOT >"$chkfile"
fc29efc3
WD
95.f..tp$dots bar/baz/rsync
96.d..t.$dots foo/
97.f..t.$dots foo/config1
98>fcstp$dots foo/config2
1ed9018e 99cLc$T.$dots foo/sym -> ../bar/baz/rsync
5794112a 100EOT
4f3be36e 101diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
5794112a 102
309a5be8 103cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
e73ad2be 104chmod 600 "$fromdir/foo/config2"
5794112a
WD
105# Lack of -t is for unchanged hard-link stress-test!
106$RSYNC -vvplrH "$fromdir/" "$todir/" \
5794112a 107 | tee "$outfile"
8af1bc90 108filter_outfile
9b9d5f89 109cat <<EOT >"$chkfile"
5794112a
WD
110bar/baz/rsync is uptodate
111foo/config1 is uptodate
112foo/config2
badb8c24 113foo/extra is uptodate
5794112a
WD
114foo/sym is uptodate
115EOT
4f3be36e 116diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
5794112a
WD
117
118chmod 747 "$todir/bar/baz/rsync"
119$RSYNC -a -f '-! */' "$fromdir/" "$todir"
120$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
5794112a 121 | tee "$outfile"
8af1bc90 122filter_outfile
9b9d5f89 123cat <<EOT >"$chkfile"
fc29efc3
WD
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
5794112a 133EOT
4f3be36e 134diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
5794112a
WD
135
136chmod 757 "$todir/foo/config1"
137touch "$todir/foo/config2"
138$RSYNC -vplrtH "$fromdir/" "$todir/" \
5794112a 139 | tee "$outfile"
8af1bc90 140filter_outfile
9b9d5f89 141cat <<EOT >"$chkfile"
5794112a
WD
142foo/config2
143EOT
4f3be36e 144diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
5794112a
WD
145
146chmod 757 "$todir/foo/config1"
147touch "$todir/foo/config2"
148$RSYNC -iplrtH "$fromdir/" "$todir/" \
149 | tee "$outfile"
9b9d5f89 150cat <<EOT >"$chkfile"
fc29efc3
WD
151.f...p$dots foo/config1
152>f..t.$dots foo/config2
5794112a 153EOT
4f3be36e 154diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
5794112a 155
989b0b88 156$RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
5794112a 157 | tee "$outfile"
8af1bc90 158filter_outfile
1ed56a05 159case `tail -1 "$outfile"` in
1ed9018e
WD
160cLc.t*)
161 sym_dots="c.t.$dots"
fc29efc3 162 L_sym_dots="cL$sym_dots"
1ed56a05
WD
163 is_uptodate='-> ../bar/baz/rsync'
164 echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
165 L=cL
166 ;;
167*)
fc29efc3
WD
168 sym_dots="$allspace"
169 L_sym_dots=".L$allspace"
1ed56a05
WD
170 is_uptodate='is uptodate'
171 touch "$chkfile.extra"
172 ;;
173esac
9b9d5f89 174cat <<EOT >"$chkfile"
fc29efc3
WD
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
1ed56a05 183cL$sym_dots foo/sym -> ../bar/baz/rsync
5794112a 184EOT
4f3be36e 185diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
5794112a 186
989b0b88
WD
187rm -rf "$to2dir"
188$RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
5794112a 189 | tee "$outfile"
1ed56a05 190cat - "$chkfile.extra" <<EOT >"$chkfile"
fc29efc3 191hf$allspace foo/extra => foo/config1
5794112a 192EOT
4f3be36e 193diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
5794112a 194
989b0b88
WD
195rm -rf "$to2dir"
196$RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6
WD
197 | tee "$outfile"
198filter_outfile
9b9d5f89 199cat <<EOT >"$chkfile"
c202424a
WD
200./ is uptodate
201bar/ is uptodate
202bar/baz/ is uptodate
165dd4a6 203bar/baz/rsync is uptodate
c202424a 204foo/ is uptodate
165dd4a6
WD
205foo/config1 is uptodate
206foo/config2 is uptodate
165dd4a6 207foo/extra => foo/config1
1ed56a05 208foo/sym $is_uptodate
165dd4a6
WD
209EOT
210diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
211
989b0b88
WD
212rm -rf "$to2dir"
213$RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6
WD
214 | tee "$outfile"
215filter_outfile
9b9d5f89 216cat <<EOT >"$chkfile"
fc29efc3
WD
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
1ed56a05 225$L$sym_dots foo/sym -> ../bar/baz/rsync
165dd4a6
WD
226EOT
227diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
228
989b0b88
WD
229rm -rf "$to2dir"
230$RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
db3ae95c 231 | tee "$outfile"
1ed56a05 232cat - "$chkfile.extra" <<EOT >"$chkfile"
db3ae95c
WD
233EOT
234diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
235
989b0b88
WD
236rm -rf "$to2dir"
237$RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
165dd4a6 238 | tee "$outfile"
1ed56a05 239cat - "$chkfile.extra" <<EOT >"$chkfile"
165dd4a6 240EOT
558d482c 241diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
165dd4a6 242
989b0b88
WD
243rm -rf "$to2dir"
244$RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6
WD
245 | tee "$outfile"
246filter_outfile
9b9d5f89 247cat <<EOT >"$chkfile"
c202424a
WD
248./ is uptodate
249bar/ is uptodate
250bar/baz/ is uptodate
165dd4a6 251bar/baz/rsync is uptodate
c202424a 252foo/ is uptodate
165dd4a6
WD
253foo/config1 is uptodate
254foo/config2 is uptodate
badb8c24 255foo/extra is uptodate
1ed56a05 256foo/sym $is_uptodate
165dd4a6 257EOT
558d482c 258diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
165dd4a6 259
989b0b88
WD
260rm -rf "$to2dir"
261$RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6
WD
262 | tee "$outfile"
263filter_outfile
9b9d5f89 264cat <<EOT >"$chkfile"
fc29efc3
WD
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
1ed56a05 273$L_sym_dots foo/sym -> ../bar/baz/rsync
165dd4a6 274EOT
558d482c 275diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
165dd4a6 276
989b0b88
WD
277rm -rf "$to2dir"
278$RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6 279 | tee "$outfile"
1ed56a05 280cat - "$chkfile.extra" <<EOT >"$chkfile"
165dd4a6 281EOT
558d482c 282diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
165dd4a6 283
989b0b88
WD
284rm -rf "$to2dir"
285$RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
165dd4a6
WD
286 | tee "$outfile"
287filter_outfile
9b9d5f89 288cat <<EOT >"$chkfile"
c202424a
WD
289./ is uptodate
290bar/ is uptodate
291bar/baz/ is uptodate
165dd4a6 292bar/baz/rsync is uptodate
c202424a 293foo/ is uptodate
165dd4a6
WD
294foo/config1 is uptodate
295foo/config2 is uptodate
badb8c24 296foo/extra is uptodate
1ed56a05 297foo/sym $is_uptodate
165dd4a6 298EOT
558d482c 299diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
165dd4a6 300
5794112a
WD
301# The script would have aborted on error, so getting here means we've won.
302exit 0