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