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