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