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" | |
9b9d5f89 | 40 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
41 | cd+++++++++ ./ |
42 | cd+++++++++ bar/ | |
1c3344a1 WD |
43 | cd+++++++++ bar/baz/ |
44 | >f+++++++++ bar/baz/rsync | |
9b9d5f89 | 45 | cd+++++++++ foo/ |
1c3344a1 WD |
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" | |
9b9d5f89 | 60 | cat <<EOT >"$chkfile" |
1c3344a1 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" | |
9b9d5f89 | 80 | cat <<EOT >"$chkfile" |
1c3344a1 | 81 | .f..tp..... bar/baz/rsync |
9b9d5f89 | 82 | .d..t...... foo/ |
1c3344a1 WD |
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 |
9b9d5f89 | 95 | cat <<EOT >"$chkfile" |
5794112a WD |
96 | bar/baz/rsync is uptodate |
97 | foo/config1 is uptodate | |
98 | foo/config2 | |
badb8c24 | 99 | foo/extra is uptodate |
5794112a WD |
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 |
9b9d5f89 | 109 | cat <<EOT >"$chkfile" |
1c3344a1 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 |
9b9d5f89 | 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" | |
9b9d5f89 | 136 | cat <<EOT >"$chkfile" |
1c3344a1 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 |
9b9d5f89 | 145 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
146 | cd ./ |
147 | cd bar/ | |
148 | cd bar/baz/ | |
149 | cf bar/baz/rsync | |
150 | cd foo/ | |
151 | cf foo/config1 | |
152 | cf foo/config2 | |
153 | hf foo/extra => foo/config1 | |
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" |
9b9d5f89 | 161 | cat <<EOT >"$chkfile" |
1c3344a1 | 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 | |
9b9d5f89 | 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 | |
165dd4a6 WD |
178 | foo/extra => foo/config1 |
179 | foo/sym is uptodate | |
180 | EOT | |
181 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed" | |
182 | ||
989b0b88 WD |
183 | rm -rf "$to2dir" |
184 | $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
185 | | tee "$outfile" |
186 | filter_outfile | |
9b9d5f89 | 187 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
188 | cd ./ |
189 | cd bar/ | |
190 | cd bar/baz/ | |
191 | hf bar/baz/rsync | |
192 | cd foo/ | |
193 | hf foo/config1 | |
194 | hf foo/config2 | |
195 | hf foo/extra => foo/config1 | |
196 | $L foo/sym -> ../bar/baz/rsync | |
165dd4a6 WD |
197 | EOT |
198 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed" | |
199 | ||
989b0b88 WD |
200 | rm -rf "$to2dir" |
201 | $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \ | |
db3ae95c | 202 | | tee "$outfile" |
9b9d5f89 | 203 | cat <<EOT >"$chkfile" |
db3ae95c WD |
204 | EOT |
205 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed" | |
206 | ||
989b0b88 WD |
207 | rm -rf "$to2dir" |
208 | $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \ | |
165dd4a6 | 209 | | tee "$outfile" |
9b9d5f89 | 210 | cat <<EOT >"$chkfile" |
165dd4a6 | 211 | EOT |
558d482c | 212 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed" |
165dd4a6 | 213 | |
989b0b88 WD |
214 | rm -rf "$to2dir" |
215 | $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
216 | | tee "$outfile" |
217 | filter_outfile | |
9b9d5f89 | 218 | cat <<EOT >"$chkfile" |
c202424a WD |
219 | ./ is uptodate |
220 | bar/ is uptodate | |
221 | bar/baz/ is uptodate | |
165dd4a6 | 222 | bar/baz/rsync is uptodate |
c202424a | 223 | foo/ is uptodate |
165dd4a6 WD |
224 | foo/config1 is uptodate |
225 | foo/config2 is uptodate | |
badb8c24 | 226 | foo/extra is uptodate |
165dd4a6 WD |
227 | foo/sym is uptodate |
228 | EOT | |
558d482c | 229 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed" |
165dd4a6 | 230 | |
989b0b88 WD |
231 | rm -rf "$to2dir" |
232 | $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
233 | | tee "$outfile" |
234 | filter_outfile | |
9b9d5f89 | 235 | cat <<EOT >"$chkfile" |
1c3344a1 WD |
236 | cd ./ |
237 | cd bar/ | |
238 | cd bar/baz/ | |
239 | .f bar/baz/rsync | |
240 | cd foo/ | |
241 | .f foo/config1 | |
242 | .f foo/config2 | |
243 | .f foo/extra | |
244 | .L foo/sym -> ../bar/baz/rsync | |
165dd4a6 | 245 | EOT |
558d482c | 246 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed" |
165dd4a6 | 247 | |
989b0b88 WD |
248 | rm -rf "$to2dir" |
249 | $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 | 250 | | tee "$outfile" |
9b9d5f89 | 251 | cat <<EOT >"$chkfile" |
165dd4a6 | 252 | EOT |
558d482c | 253 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed" |
165dd4a6 | 254 | |
989b0b88 WD |
255 | rm -rf "$to2dir" |
256 | $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ | |
165dd4a6 WD |
257 | | tee "$outfile" |
258 | filter_outfile | |
9b9d5f89 | 259 | cat <<EOT >"$chkfile" |
c202424a WD |
260 | ./ is uptodate |
261 | bar/ is uptodate | |
262 | bar/baz/ is uptodate | |
165dd4a6 | 263 | bar/baz/rsync is uptodate |
c202424a | 264 | foo/ is uptodate |
165dd4a6 WD |
265 | foo/config1 is uptodate |
266 | foo/config2 is uptodate | |
badb8c24 | 267 | foo/extra is uptodate |
165dd4a6 WD |
268 | foo/sym is uptodate |
269 | EOT | |
558d482c | 270 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed" |
165dd4a6 | 271 | |
5794112a WD |
272 | # The script would have aborted on error, so getting here means we've won. |
273 | exit 0 |