Simplified the regular expressions for sed due to problems on some
[rsync/rsync.git] / testsuite / itemize.test
... / ...
CommitLineData
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
15lddir="$tmpdir/ld"
16
17chkfile="$scratchdir/rsync.chk"
18outfile="$scratchdir/rsync.out"
19
20filter_outfile() {
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' \
26 -e '/^$/,$d' \
27 <"$outfile" >"$outfile.new"
28 mv "$outfile.new" "$outfile"
29}
30
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"
36chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
37umask 0
38ln -s ../bar/baz/rsync "$fromdir/foo/sym"
39umask 022
40ln "$fromdir/foo/config1" "$fromdir/foo/extra"
41
42$RSYNC -iplr "$fromdir/" "$todir/" \
43 | tee "$outfile"
44cat <<EOT >"$chkfile"
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
54diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
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"
60chmod 601 "$fromdir/foo/config2"
61$RSYNC -iplrH "$fromdir/" "$todir/" \
62 | tee "$outfile"
63cat <<EOT >"$chkfile"
64>f..T.... bar/baz/rsync
65>f..T.... foo/config1
66>f.sTp... foo/config2
67hf..T.... foo/extra => foo/config1
68EOT
69diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
70
71$RSYNC -a -f '-! */' "$fromdir/" "$todir"
72sleep 1 # For directory mod below to ensure time difference
73rm "$todir/foo/sym"
74umask 0
75ln -s ../bar/baz "$todir/foo/sym"
76umask 022
77cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
78chmod 600 "$fromdir/foo/config2"
79chmod 777 "$todir/bar/baz/rsync"
80
81$RSYNC -iplrtc "$fromdir/" "$todir/" \
82 | tee "$outfile"
83cat <<EOT >"$chkfile"
84.f..tp... bar/baz/rsync
85.d..t.... foo/
86.f..t.... foo/config1
87>fcstp... foo/config2
88cL..T.... foo/sym -> ../bar/baz/rsync
89EOT
90diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
91
92cp -p "$srcdir/config.h" "$fromdir/foo/config2"
93chmod 600 "$fromdir/foo/config2"
94# Lack of -t is for unchanged hard-link stress-test!
95$RSYNC -vvplrH "$fromdir/" "$todir/" \
96 | tee "$outfile"
97cat <<EOT >"$chkfile"
98bar/baz/rsync is uptodate
99foo/config1 is uptodate
100foo/config2
101"foo/extra" is a hard link
102foo/sym is uptodate
103EOT
104filter_outfile
105diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
106
107chmod 747 "$todir/bar/baz/rsync"
108$RSYNC -a -f '-! */' "$fromdir/" "$todir"
109$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
110 | tee "$outfile"
111cat <<EOT >"$chkfile"
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
122filter_outfile
123diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
124
125chmod 757 "$todir/foo/config1"
126touch "$todir/foo/config2"
127$RSYNC -vplrtH "$fromdir/" "$todir/" \
128 | tee "$outfile"
129cat <<EOT >"$chkfile"
130foo/config2
131EOT
132filter_outfile
133diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
134
135chmod 757 "$todir/foo/config1"
136touch "$todir/foo/config2"
137$RSYNC -iplrtH "$fromdir/" "$todir/" \
138 | tee "$outfile"
139cat <<EOT >"$chkfile"
140.f...p... foo/config1
141>f..t.... foo/config2
142EOT
143diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
144
145mv "$todir" "$lddir"
146$RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
147 | tee "$outfile"
148cat <<EOT >"$chkfile"
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
159filter_outfile
160diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
161
162rm -rf "$todir"
163$RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
164 | tee "$outfile"
165cat <<EOT >"$chkfile"
166.d..t.... ./
167cd+++++++ bar/
168cd+++++++ bar/baz/
169cd+++++++ foo/
170hf+++++++ foo/extra => foo/config1
171cL+++++++ foo/sym -> ../bar/baz/rsync
172EOT
173diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
174
175# The script would have aborted on error, so getting here means we've won.
176exit 0