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