3 # Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
8 # Test the output of various copy commands to ensure itemized output
9 # and double-verbose output is correct.
11 . "$suitedir/rsync.fns"
15 chkfile="$scratchdir/rsync.chk"
16 outfile="$scratchdir/rsync.out"
18 makepath "$fromdir/foo"
19 makepath "$fromdir/bar/baz"
20 cp -p "$srcdir/configure.in" "$fromdir/foo/config1"
21 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
22 cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
23 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
25 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
27 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
29 # Check if the OS can hard-link symlinks or not.
30 # (Note: the link we check MUST NOT point to a valid file!)
31 ln -s no-such-dir "$to2dir"
32 if ln "$to2dir" "$to2dir.test" 2>/dev/null; then
37 rm -f "$to2dir" "$to2dir.test"
39 # Check if rsync can preserve time on symlinks
45 if $RSYNC --version | grep ", symtimes" >/dev/null; then
53 $RSYNC -iplr "$fromdir/" "$todir/" \
59 >f$all_plus bar/baz/rsync
61 >f$all_plus foo/config1
62 >f$all_plus foo/config2
64 cL$all_plus foo/sym -> ../bar/baz/rsync
66 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
68 # Ensure there are no accidental directory-time problems.
69 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
71 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
72 chmod 601 "$fromdir/foo/config2"
73 $RSYNC -iplrH "$fromdir/" "$todir/" \
76 >f..T.$dots bar/baz/rsync
77 >f..T.$dots foo/config1
78 >f.sTp$dots foo/config2
79 hf..T.$dots foo/extra => foo/config1
81 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
83 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
84 sleep 1 # For directory mod below to ensure time difference
87 ln -s ../bar/baz "$todir/foo/sym"
89 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
90 chmod 600 "$fromdir/foo/config2"
91 chmod 777 "$todir/bar/baz/rsync"
93 $RSYNC -iplrtc "$fromdir/" "$todir/" \
96 .f..tp$dots bar/baz/rsync
98 .f..t.$dots foo/config1
99 >fcstp$dots foo/config2
100 cL.$T.$dots foo/sym -> ../bar/baz/rsync
102 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
104 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
105 chmod 600 "$fromdir/foo/config2"
106 # Lack of -t is for unchanged hard-link stress-test!
107 $RSYNC -vvplrH "$fromdir/" "$todir/" \
110 cat <<EOT >"$chkfile"
111 bar/baz/rsync is uptodate
112 foo/config1 is uptodate
114 foo/extra is uptodate
117 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
119 chmod 747 "$todir/bar/baz/rsync"
120 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
121 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
124 cat <<EOT >"$chkfile"
128 .f...p$dots bar/baz/rsync
130 .f$allspace foo/config1
131 >f..t.$dots foo/config2
132 hf$allspace foo/extra
133 .L$allspace foo/sym -> ../bar/baz/rsync
135 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
137 chmod 757 "$todir/foo/config1"
138 touch "$todir/foo/config2"
139 $RSYNC -vplrtH "$fromdir/" "$todir/" \
142 cat <<EOT >"$chkfile"
145 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
147 chmod 757 "$todir/foo/config1"
148 touch "$todir/foo/config2"
149 $RSYNC -iplrtH "$fromdir/" "$todir/" \
151 cat <<EOT >"$chkfile"
152 .f...p$dots foo/config1
153 >f..t.$dots foo/config2
155 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
157 $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
160 case `tail -1 "$outfile"` in
163 L_sym_dots="cL$sym_dots"
164 is_uptodate='-> ../bar/baz/rsync'
165 echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
170 L_sym_dots=".L$allspace"
171 is_uptodate='is uptodate'
172 touch "$chkfile.extra"
175 cat <<EOT >"$chkfile"
179 cf$allspace bar/baz/rsync
181 cf$allspace foo/config1
182 cf$allspace foo/config2
183 hf$allspace foo/extra => foo/config1
184 cL$sym_dots foo/sym -> ../bar/baz/rsync
186 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
189 $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
191 cat - "$chkfile.extra" <<EOT >"$chkfile"
192 hf$allspace foo/extra => foo/config1
194 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
197 $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
200 cat <<EOT >"$chkfile"
204 bar/baz/rsync is uptodate
206 foo/config1 is uptodate
207 foo/config2 is uptodate
208 foo/extra => foo/config1
211 diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
214 $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
217 cat <<EOT >"$chkfile"
221 hf$allspace bar/baz/rsync
223 hf$allspace foo/config1
224 hf$allspace foo/config2
225 hf$allspace foo/extra => foo/config1
226 $L$sym_dots foo/sym -> ../bar/baz/rsync
228 diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
231 $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
233 cat - "$chkfile.extra" <<EOT >"$chkfile"
235 diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
238 $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
240 cat - "$chkfile.extra" <<EOT >"$chkfile"
242 diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
245 $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
248 cat <<EOT >"$chkfile"
252 bar/baz/rsync is uptodate
254 foo/config1 is uptodate
255 foo/config2 is uptodate
256 foo/extra is uptodate
259 diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
262 $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
265 cat <<EOT >"$chkfile"
269 .f$allspace bar/baz/rsync
271 .f$allspace foo/config1
272 .f$allspace foo/config2
273 .f$allspace foo/extra
274 $L_sym_dots foo/sym -> ../bar/baz/rsync
276 diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
279 $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
281 cat - "$chkfile.extra" <<EOT >"$chkfile"
283 diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
286 $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
289 cat <<EOT >"$chkfile"
293 bar/baz/rsync is uptodate
295 foo/config1 is uptodate
296 foo/config2 is uptodate
297 foo/extra is uptodate
300 diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
302 # The script would have aborted on error, so getting here means we've won.