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