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