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