Commit | Line | Data |
---|---|---|
5794112a WD |
1 | #! /bin/sh |
2 | ||
3 | # Copyright (C) 2005 by Wayne Davison <wayned@samba.org> | |
4 | ||
c8d19f90 | 5 | # This program is distributable under the terms of the GNU GPL (see |
5794112a WD |
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 | ||
989b0b88 | 13 | to2dir="$tmpdir/to2" |
5794112a | 14 | |
4f3be36e | 15 | chkfile="$scratchdir/rsync.chk" |
5794112a WD |
16 | outfile="$scratchdir/rsync.out" |
17 | ||
18 | makepath "$fromdir/foo" | |
19 | makepath "$fromdir/bar/baz" | |
309a5be8 | 20 | cp -p "$srcdir/configure.in" "$fromdir/foo/config1" |
5794112a WD |
21 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
22 | cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync" | |
e73ad2be | 23 | chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync" |
87a57a30 | 24 | umask 0 |
5794112a | 25 | ln -s ../bar/baz/rsync "$fromdir/foo/sym" |
87a57a30 | 26 | umask 022 |
5794112a WD |
27 | ln "$fromdir/foo/config1" "$fromdir/foo/extra" |
28 | ||
717d0466 WD |
29 | # Check if the OS can hard-link symlinks or not. |
30 | # (Note: the link we check MUST NOT point to a valid file!) | |
31 | ln -s no-such-dir "$to2dir" | |
32 | if ln "$to2dir" "$to2dir.test" 2>/dev/null; then | |
3aeedbfd WD |
33 | L=hL |
34 | else | |
35 | L=cL | |
36 | fi | |
717d0466 | 37 | rm -f "$to2dir" "$to2dir.test" |
1ed56a05 WD |
38 | |
39 | # Check if rsync can preserve time on symlinks | |
40 | case "$RSYNC" in | |
41 | *protocol=2*) | |
42 | T=.T | |
43 | ;; | |
44 | *) | |
45 | if $RSYNC --version | grep ", symtimes" >/dev/null; then | |
46 | T=.t | |
47 | else | |
48 | T=.T | |
49 | fi | |
50 | ;; | |
51 | esac | |
3b8ed842 | 52 | |
5794112a WD |
53 | $RSYNC -iplr "$fromdir/" "$todir/" \ |
54 | | tee "$outfile" | |
9b9d5f89 | 55 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
56 | cd+++++++++ ./ |
57 | cd+++++++++ bar/ | |
1c3344a1 WD |
58 | cd+++++++++ bar/baz/ |
59 | >f+++++++++ bar/baz/rsync | |
9b9d5f89 | 60 | cd+++++++++ foo/ |
1c3344a1 WD |
61 | >f+++++++++ foo/config1 |
62 | >f+++++++++ foo/config2 | |
63 | >f+++++++++ foo/extra | |
64 | cL+++++++++ foo/sym -> ../bar/baz/rsync | |
5794112a | 65 | EOT |
4f3be36e | 66 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed" |
5794112a WD |
67 | |
68 | # Ensure there are no accidental directory-time problems. | |
69 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
70 | ||
309a5be8 | 71 | cp -p "$srcdir/configure.in" "$fromdir/foo/config2" |
e73ad2be | 72 | chmod 601 "$fromdir/foo/config2" |
5794112a WD |
73 | $RSYNC -iplrH "$fromdir/" "$todir/" \ |
74 | | tee "$outfile" | |
9b9d5f89 | 75 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
76 | >f..T...... bar/baz/rsync |
77 | >f..T...... foo/config1 | |
78 | >f.sTp..... foo/config2 | |
79 | hf..T...... foo/extra => foo/config1 | |
5794112a | 80 | EOT |
4f3be36e | 81 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed" |
5794112a WD |
82 | |
83 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
84 | sleep 1 # For directory mod below to ensure time difference | |
85 | rm "$todir/foo/sym" | |
a3dcb790 | 86 | umask 0 |
5794112a | 87 | ln -s ../bar/baz "$todir/foo/sym" |
a3dcb790 | 88 | umask 022 |
5794112a | 89 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
e73ad2be | 90 | chmod 600 "$fromdir/foo/config2" |
5794112a WD |
91 | chmod 777 "$todir/bar/baz/rsync" |
92 | ||
93 | $RSYNC -iplrtc "$fromdir/" "$todir/" \ | |
94 | | tee "$outfile" | |
9b9d5f89 | 95 | cat <<EOT >"$chkfile" |
1c3344a1 | 96 | .f..tp..... bar/baz/rsync |
9b9d5f89 | 97 | .d..t...... foo/ |
1c3344a1 WD |
98 | .f..t...... foo/config1 |
99 | >fcstp..... foo/config2 | |
1ed56a05 | 100 | cL.$T...... foo/sym -> ../bar/baz/rsync |
5794112a | 101 | EOT |
4f3be36e | 102 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed" |
5794112a | 103 | |
309a5be8 | 104 | cp -p "$srcdir/configure.in" "$fromdir/foo/config2" |
e73ad2be | 105 | chmod 600 "$fromdir/foo/config2" |
5794112a WD |
106 | # Lack of -t is for unchanged hard-link stress-test! |
107 | $RSYNC -vvplrH "$fromdir/" "$todir/" \ | |
5794112a | 108 | | tee "$outfile" |
8af1bc90 | 109 | filter_outfile |
9b9d5f89 | 110 | cat <<EOT >"$chkfile" |
5794112a WD |
111 | bar/baz/rsync is uptodate |
112 | foo/config1 is uptodate | |
113 | foo/config2 | |
badb8c24 | 114 | foo/extra is uptodate |
5794112a WD |
115 | foo/sym is uptodate |
116 | EOT | |
4f3be36e | 117 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed" |
5794112a WD |
118 | |
119 | chmod 747 "$todir/bar/baz/rsync" | |
120 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
121 | $RSYNC -ivvplrtH "$fromdir/" "$todir/" \ | |
5794112a | 122 | | tee "$outfile" |
8af1bc90 | 123 | filter_outfile |
9b9d5f89 | 124 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
125 | .d ./ |
126 | .d bar/ | |
127 | .d bar/baz/ | |
128 | .f...p..... bar/baz/rsync | |
129 | .d foo/ | |
130 | .f foo/config1 | |
131 | >f..t...... foo/config2 | |
132 | hf foo/extra | |
133 | .L foo/sym -> ../bar/baz/rsync | |
5794112a | 134 | EOT |
4f3be36e | 135 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed" |
5794112a WD |
136 | |
137 | chmod 757 "$todir/foo/config1" | |
138 | touch "$todir/foo/config2" | |
139 | $RSYNC -vplrtH "$fromdir/" "$todir/" \ | |
5794112a | 140 | | tee "$outfile" |
8af1bc90 | 141 | filter_outfile |
9b9d5f89 | 142 | cat <<EOT >"$chkfile" |
5794112a WD |
143 | foo/config2 |
144 | EOT | |
4f3be36e | 145 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed" |
5794112a WD |
146 | |
147 | chmod 757 "$todir/foo/config1" | |
148 | touch "$todir/foo/config2" | |
149 | $RSYNC -iplrtH "$fromdir/" "$todir/" \ | |
150 | | tee "$outfile" | |
9b9d5f89 | 151 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
152 | .f...p..... foo/config1 |
153 | >f..t...... foo/config2 | |
5794112a | 154 | EOT |
4f3be36e | 155 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed" |
5794112a | 156 | |
989b0b88 | 157 | $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \ |
5794112a | 158 | | tee "$outfile" |
8af1bc90 | 159 | filter_outfile |
1ed56a05 WD |
160 | case `tail -1 "$outfile"` in |
161 | cL..t*) | |
162 | sym_dots='..t......' | |
163 | L_sym_dots='cL..t......' | |
164 | is_uptodate='-> ../bar/baz/rsync' | |
165 | echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra" | |
166 | L=cL | |
167 | ;; | |
168 | *) | |
169 | sym_dots=' ' | |
170 | L_sym_dots='.L ' | |
171 | is_uptodate='is uptodate' | |
172 | touch "$chkfile.extra" | |
173 | ;; | |
174 | esac | |
9b9d5f89 | 175 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
176 | cd ./ |
177 | cd bar/ | |
178 | cd bar/baz/ | |
179 | cf bar/baz/rsync | |
180 | cd foo/ | |
181 | cf foo/config1 | |
182 | cf foo/config2 | |
183 | hf foo/extra => foo/config1 | |
1ed56a05 | 184 | cL$sym_dots foo/sym -> ../bar/baz/rsync |
5794112a | 185 | EOT |
4f3be36e | 186 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed" |
5794112a | 187 | |
989b0b88 WD |
188 | rm -rf "$to2dir" |
189 | $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \ | |
5794112a | 190 | | tee "$outfile" |
1ed56a05 | 191 | cat - "$chkfile.extra" <<EOT >"$chkfile" |
1c3344a1 | 192 | hf foo/extra => foo/config1 |
5794112a | 193 | EOT |
4f3be36e | 194 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed" |
5794112a | 195 | |
989b0b88 WD |
196 | rm -rf "$to2dir" |
197 | $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
198 | | tee "$outfile" |
199 | filter_outfile | |
9b9d5f89 | 200 | cat <<EOT >"$chkfile" |
c202424a WD |
201 | ./ is uptodate |
202 | bar/ is uptodate | |
203 | bar/baz/ is uptodate | |
165dd4a6 | 204 | bar/baz/rsync is uptodate |
c202424a | 205 | foo/ is uptodate |
165dd4a6 WD |
206 | foo/config1 is uptodate |
207 | foo/config2 is uptodate | |
165dd4a6 | 208 | foo/extra => foo/config1 |
1ed56a05 | 209 | foo/sym $is_uptodate |
165dd4a6 WD |
210 | EOT |
211 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed" | |
212 | ||
989b0b88 WD |
213 | rm -rf "$to2dir" |
214 | $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
215 | | tee "$outfile" |
216 | filter_outfile | |
9b9d5f89 | 217 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
218 | cd ./ |
219 | cd bar/ | |
220 | cd bar/baz/ | |
221 | hf bar/baz/rsync | |
222 | cd foo/ | |
223 | hf foo/config1 | |
224 | hf foo/config2 | |
225 | hf foo/extra => foo/config1 | |
1ed56a05 | 226 | $L$sym_dots foo/sym -> ../bar/baz/rsync |
165dd4a6 WD |
227 | EOT |
228 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed" | |
229 | ||
989b0b88 WD |
230 | rm -rf "$to2dir" |
231 | $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \ | |
db3ae95c | 232 | | tee "$outfile" |
1ed56a05 | 233 | cat - "$chkfile.extra" <<EOT >"$chkfile" |
db3ae95c WD |
234 | EOT |
235 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed" | |
236 | ||
989b0b88 WD |
237 | rm -rf "$to2dir" |
238 | $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \ | |
165dd4a6 | 239 | | tee "$outfile" |
1ed56a05 | 240 | cat - "$chkfile.extra" <<EOT >"$chkfile" |
165dd4a6 | 241 | EOT |
558d482c | 242 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed" |
165dd4a6 | 243 | |
989b0b88 WD |
244 | rm -rf "$to2dir" |
245 | $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
246 | | tee "$outfile" |
247 | filter_outfile | |
9b9d5f89 | 248 | cat <<EOT >"$chkfile" |
c202424a WD |
249 | ./ is uptodate |
250 | bar/ is uptodate | |
251 | bar/baz/ is uptodate | |
165dd4a6 | 252 | bar/baz/rsync is uptodate |
c202424a | 253 | foo/ is uptodate |
165dd4a6 WD |
254 | foo/config1 is uptodate |
255 | foo/config2 is uptodate | |
badb8c24 | 256 | foo/extra is uptodate |
1ed56a05 | 257 | foo/sym $is_uptodate |
165dd4a6 | 258 | EOT |
558d482c | 259 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed" |
165dd4a6 | 260 | |
989b0b88 WD |
261 | rm -rf "$to2dir" |
262 | $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
263 | | tee "$outfile" |
264 | filter_outfile | |
9b9d5f89 | 265 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
266 | cd ./ |
267 | cd bar/ | |
268 | cd bar/baz/ | |
269 | .f bar/baz/rsync | |
270 | cd foo/ | |
271 | .f foo/config1 | |
272 | .f foo/config2 | |
273 | .f foo/extra | |
1ed56a05 | 274 | $L_sym_dots foo/sym -> ../bar/baz/rsync |
165dd4a6 | 275 | EOT |
558d482c | 276 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed" |
165dd4a6 | 277 | |
989b0b88 WD |
278 | rm -rf "$to2dir" |
279 | $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 | 280 | | tee "$outfile" |
1ed56a05 | 281 | cat - "$chkfile.extra" <<EOT >"$chkfile" |
165dd4a6 | 282 | EOT |
558d482c | 283 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed" |
165dd4a6 | 284 | |
989b0b88 WD |
285 | rm -rf "$to2dir" |
286 | $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
287 | | tee "$outfile" |
288 | filter_outfile | |
9b9d5f89 | 289 | cat <<EOT >"$chkfile" |
c202424a WD |
290 | ./ is uptodate |
291 | bar/ is uptodate | |
292 | bar/baz/ is uptodate | |
165dd4a6 | 293 | bar/baz/rsync is uptodate |
c202424a | 294 | foo/ is uptodate |
165dd4a6 WD |
295 | foo/config1 is uptodate |
296 | foo/config2 is uptodate | |
badb8c24 | 297 | foo/extra is uptodate |
1ed56a05 | 298 | foo/sym $is_uptodate |
165dd4a6 | 299 | EOT |
558d482c | 300 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed" |
165dd4a6 | 301 | |
5794112a WD |
302 | # The script would have aborted on error, so getting here means we've won. |
303 | exit 0 |