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