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