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