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