Simplified the regular expressions for sed due to problems on some
[rsync/rsync.git] / testsuite / itemize.test
CommitLineData
5794112a
WD
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
13set -x
14
5794112a
WD
15lddir="$tmpdir/ld"
16
4f3be36e 17chkfile="$scratchdir/rsync.chk"
5794112a
WD
18outfile="$scratchdir/rsync.out"
19
4f3be36e 20filter_outfile() {
6a12f0d6
WD
21 sed -e '/^building file list /d' \
22 -e '/^created directory /d' \
23 -e '/^done$/d' \
24 -e '/ --whole-file$/d' \
25 -e '/^total: /d' \
4f3be36e
WD
26 -e '/^$/,$d' \
27 <"$outfile" >"$outfile.new"
28 mv "$outfile.new" "$outfile"
29}
30
5794112a
WD
31makepath "$fromdir/foo"
32makepath "$fromdir/bar/baz"
33cp -p "$srcdir/config.h" "$fromdir/foo/config1"
34cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
35cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
e73ad2be 36chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
87a57a30 37umask 0
5794112a 38ln -s ../bar/baz/rsync "$fromdir/foo/sym"
87a57a30 39umask 022
5794112a
WD
40ln "$fromdir/foo/config1" "$fromdir/foo/extra"
41
42$RSYNC -iplr "$fromdir/" "$todir/" \
43 | tee "$outfile"
4f3be36e 44cat <<EOT >"$chkfile"
5794112a
WD
45cd+++++++ bar/
46cd+++++++ bar/baz/
47>f+++++++ bar/baz/rsync
48cd+++++++ foo/
49>f+++++++ foo/config1
50>f+++++++ foo/config2
51>f+++++++ foo/extra
52cL+++++++ foo/sym -> ../bar/baz/rsync
53EOT
4f3be36e 54diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
5794112a
WD
55
56# Ensure there are no accidental directory-time problems.
57$RSYNC -a -f '-! */' "$fromdir/" "$todir"
58
59cp -p "$srcdir/config.h" "$fromdir/foo/config2"
e73ad2be 60chmod 601 "$fromdir/foo/config2"
5794112a
WD
61$RSYNC -iplrH "$fromdir/" "$todir/" \
62 | tee "$outfile"
4f3be36e 63cat <<EOT >"$chkfile"
5794112a
WD
64>f..T.... bar/baz/rsync
65>f..T.... foo/config1
e73ad2be 66>f.sTp... foo/config2
5794112a
WD
67hf..T.... foo/extra => foo/config1
68EOT
4f3be36e 69diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
5794112a
WD
70
71$RSYNC -a -f '-! */' "$fromdir/" "$todir"
72sleep 1 # For directory mod below to ensure time difference
73rm "$todir/foo/sym"
a3dcb790 74umask 0
5794112a 75ln -s ../bar/baz "$todir/foo/sym"
a3dcb790 76umask 022
5794112a 77cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
e73ad2be 78chmod 600 "$fromdir/foo/config2"
5794112a
WD
79chmod 777 "$todir/bar/baz/rsync"
80
81$RSYNC -iplrtc "$fromdir/" "$todir/" \
82 | tee "$outfile"
4f3be36e 83cat <<EOT >"$chkfile"
5794112a
WD
84.f..tp... bar/baz/rsync
85.d..t.... foo/
86.f..t.... foo/config1
e73ad2be 87>fcstp... foo/config2
5794112a
WD
88cL..T.... foo/sym -> ../bar/baz/rsync
89EOT
4f3be36e 90diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
5794112a
WD
91
92cp -p "$srcdir/config.h" "$fromdir/foo/config2"
e73ad2be 93chmod 600 "$fromdir/foo/config2"
5794112a
WD
94# Lack of -t is for unchanged hard-link stress-test!
95$RSYNC -vvplrH "$fromdir/" "$todir/" \
5794112a 96 | tee "$outfile"
4f3be36e 97cat <<EOT >"$chkfile"
5794112a
WD
98bar/baz/rsync is uptodate
99foo/config1 is uptodate
100foo/config2
101"foo/extra" is a hard link
102foo/sym is uptodate
103EOT
4f3be36e
WD
104filter_outfile
105diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
5794112a
WD
106
107chmod 747 "$todir/bar/baz/rsync"
108$RSYNC -a -f '-! */' "$fromdir/" "$todir"
109$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
5794112a 110 | tee "$outfile"
4f3be36e 111cat <<EOT >"$chkfile"
5794112a
WD
112.d ./
113.d bar/
114.d bar/baz/
115.f...p... bar/baz/rsync
116.d foo/
117.f foo/config1
118>f..t.... foo/config2
119hf foo/extra
120.L foo/sym -> ../bar/baz/rsync
121EOT
4f3be36e
WD
122filter_outfile
123diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
5794112a
WD
124
125chmod 757 "$todir/foo/config1"
126touch "$todir/foo/config2"
127$RSYNC -vplrtH "$fromdir/" "$todir/" \
5794112a 128 | tee "$outfile"
4f3be36e 129cat <<EOT >"$chkfile"
5794112a
WD
130foo/config2
131EOT
4f3be36e
WD
132filter_outfile
133diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
5794112a
WD
134
135chmod 757 "$todir/foo/config1"
136touch "$todir/foo/config2"
137$RSYNC -iplrtH "$fromdir/" "$todir/" \
138 | tee "$outfile"
4f3be36e 139cat <<EOT >"$chkfile"
5794112a
WD
140.f...p... foo/config1
141>f..t.... foo/config2
142EOT
4f3be36e 143diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
5794112a
WD
144
145mv "$todir" "$lddir"
146$RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
5794112a 147 | tee "$outfile"
4f3be36e 148cat <<EOT >"$chkfile"
5794112a
WD
149.d..t.... ./
150cd+++++++ bar/
151cd+++++++ bar/baz/
152cf....... bar/baz/rsync
153cd+++++++ foo/
154cf....... foo/config1
155cf....... foo/config2
156hf+++++++ foo/extra => foo/config1
157cL+++++++ foo/sym -> ../bar/baz/rsync
158EOT
4f3be36e
WD
159filter_outfile
160diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
5794112a
WD
161
162rm -rf "$todir"
163$RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
164 | tee "$outfile"
4f3be36e 165cat <<EOT >"$chkfile"
5794112a
WD
166.d..t.... ./
167cd+++++++ bar/
168cd+++++++ bar/baz/
169cd+++++++ foo/
170hf+++++++ foo/extra => foo/config1
171cL+++++++ foo/sym -> ../bar/baz/rsync
172EOT
4f3be36e 173diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
5794112a
WD
174
175# The script would have aborted on error, so getting here means we've won.
176exit 0