Changed to reflect new (more correct) output of what updating is
[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 lddir="$tmpdir/ld"
14
15 chkfile="$scratchdir/rsync.chk"
16 outfile="$scratchdir/rsync.out"
17
18 makepath "$fromdir/foo"
19 makepath "$fromdir/bar/baz"
20 cp -p "$srcdir/configure.in" "$fromdir/foo/config1"
21 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
22 cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
23 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
24 umask 0
25 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
26 umask 022
27 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
28
29 $RSYNC -iplr "$fromdir/" "$todir/" \
30     | tee "$outfile"
31 cat <<EOT >"$chkfile"
32 cd+++++++ ./
33 cd+++++++ bar/
34 cd+++++++ bar/baz/
35 >f+++++++ bar/baz/rsync
36 cd+++++++ foo/
37 >f+++++++ foo/config1
38 >f+++++++ foo/config2
39 >f+++++++ foo/extra
40 cL+++++++ foo/sym -> ../bar/baz/rsync
41 EOT
42 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
43
44 # Ensure there are no accidental directory-time problems.
45 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
46
47 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
48 chmod 601 "$fromdir/foo/config2"
49 $RSYNC -iplrH "$fromdir/" "$todir/" \
50     | tee "$outfile"
51 cat <<EOT >"$chkfile"
52 >f..T.... bar/baz/rsync
53 >f..T.... foo/config1
54 >f.sTp... foo/config2
55 hf..T.... foo/extra => foo/config1
56 EOT
57 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
58
59 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
60 sleep 1 # For directory mod below to ensure time difference
61 rm "$todir/foo/sym"
62 umask 0
63 ln -s ../bar/baz "$todir/foo/sym"
64 umask 022
65 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
66 chmod 600 "$fromdir/foo/config2"
67 chmod 777 "$todir/bar/baz/rsync"
68
69 $RSYNC -iplrtc "$fromdir/" "$todir/" \
70     | tee "$outfile"
71 cat <<EOT >"$chkfile"
72 .f..tp... bar/baz/rsync
73 .d..t.... foo/
74 .f..t.... foo/config1
75 >fcstp... foo/config2
76 cL..T.... foo/sym -> ../bar/baz/rsync
77 EOT
78 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
79
80 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
81 chmod 600 "$fromdir/foo/config2"
82 # Lack of -t is for unchanged hard-link stress-test!
83 $RSYNC -vvplrH "$fromdir/" "$todir/" \
84     | tee "$outfile"
85 filter_outfile
86 cat <<EOT >"$chkfile"
87 bar/baz/rsync is uptodate
88 foo/config1 is uptodate
89 foo/config2
90 "foo/extra" is a hard link
91 foo/sym is uptodate
92 EOT
93 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
94
95 chmod 747 "$todir/bar/baz/rsync"
96 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
97 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
98     | tee "$outfile"
99 filter_outfile
100 cat <<EOT >"$chkfile"
101 .d        ./
102 .d        bar/
103 .d        bar/baz/
104 .f...p... bar/baz/rsync
105 .d        foo/
106 .f        foo/config1
107 >f..t.... foo/config2
108 hf        foo/extra
109 .L        foo/sym -> ../bar/baz/rsync
110 EOT
111 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
112
113 chmod 757 "$todir/foo/config1"
114 touch "$todir/foo/config2"
115 $RSYNC -vplrtH "$fromdir/" "$todir/" \
116     | tee "$outfile"
117 filter_outfile
118 cat <<EOT >"$chkfile"
119 foo/config2
120 EOT
121 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
122
123 chmod 757 "$todir/foo/config1"
124 touch "$todir/foo/config2"
125 $RSYNC -iplrtH "$fromdir/" "$todir/" \
126     | tee "$outfile"
127 cat <<EOT >"$chkfile"
128 .f...p... foo/config1
129 >f..t.... foo/config2
130 EOT
131 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
132
133 mv "$todir" "$lddir"
134 $RSYNC -ivvplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
135     | tee "$outfile"
136 filter_outfile
137 cat <<EOT >"$chkfile"
138 cd        ./
139 cd        bar/
140 cd        bar/baz/
141 cf        bar/baz/rsync
142 cd        foo/
143 cf        foo/config1
144 cf        foo/config2
145 hf        foo/extra => foo/config1
146 cL        foo/sym -> ../bar/baz/rsync
147 EOT
148 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
149
150 rm -rf "$todir"
151 $RSYNC -iplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
152     | tee "$outfile"
153 cat <<EOT >"$chkfile"
154 hf        foo/extra => foo/config1
155 EOT
156 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
157
158 rm -rf "$todir"
159 $RSYNC -vvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
160     | tee "$outfile"
161 filter_outfile
162 cat <<EOT >"$chkfile"
163 ./ is uptodate
164 bar/ is uptodate
165 bar/baz/ is uptodate
166 bar/baz/rsync is uptodate
167 foo/ is uptodate
168 foo/config1 is uptodate
169 foo/config2 is uptodate
170 "foo/extra" is a hard link
171 foo/extra => foo/config1
172 foo/sym is uptodate
173 EOT
174 diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
175
176 rm -rf "$todir"
177 $RSYNC -ivvplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
178     | tee "$outfile"
179 filter_outfile
180 cat <<EOT >"$chkfile"
181 cd        ./
182 cd        bar/
183 cd        bar/baz/
184 hf        bar/baz/rsync
185 cd        foo/
186 hf        foo/config1
187 hf        foo/config2
188 hf        foo/extra => foo/config1
189 hL        foo/sym -> ../bar/baz/rsync
190 EOT
191 diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
192
193 rm -rf "$todir"
194 $RSYNC -iplrtH --dry-run --link-dest=../ld "$fromdir/" "$todir/" \
195     | tee "$outfile"
196 cat <<EOT >"$chkfile"
197 EOT
198 diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
199
200 rm -rf "$todir"
201 $RSYNC -iplrtH --link-dest=../ld "$fromdir/" "$todir/" \
202     | tee "$outfile"
203 cat <<EOT >"$chkfile"
204 EOT
205 diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
206
207 rm -rf "$todir"
208 $RSYNC -vvplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
209     | tee "$outfile"
210 filter_outfile
211 cat <<EOT >"$chkfile"
212 ./ is uptodate
213 bar/ is uptodate
214 bar/baz/ is uptodate
215 bar/baz/rsync is uptodate
216 foo/ is uptodate
217 foo/config1 is uptodate
218 foo/config2 is uptodate
219 "foo/extra" is a hard link
220 foo/sym is uptodate
221 EOT
222 diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
223
224 rm -rf "$todir"
225 $RSYNC -ivvplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
226     | tee "$outfile"
227 filter_outfile
228 # TODO fix really-old problem when combining -H with --compare-dest:
229 # missing output for foo/extra hard-link (and it might not be updated)!
230 cat <<EOT >"$chkfile"
231 cd        ./
232 cd        bar/
233 cd        bar/baz/
234 .f        bar/baz/rsync
235 cd        foo/
236 .f        foo/config1
237 .f        foo/config2
238 .L        foo/sym -> ../bar/baz/rsync
239 EOT
240 diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
241
242 rm -rf "$todir"
243 $RSYNC -iplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
244     | tee "$outfile"
245 cat <<EOT >"$chkfile"
246 EOT
247 diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
248
249 rm -rf "$todir"
250 $RSYNC -vvplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
251     | tee "$outfile"
252 filter_outfile
253 cat <<EOT >"$chkfile"
254 ./ is uptodate
255 bar/ is uptodate
256 bar/baz/ is uptodate
257 bar/baz/rsync is uptodate
258 foo/ is uptodate
259 foo/config1 is uptodate
260 foo/config2 is uptodate
261 "foo/extra" is a hard link
262 foo/sym is uptodate
263 EOT
264 diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
265
266 # The script would have aborted on error, so getting here means we've won.
267 exit 0