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"
30 # Check if rsync is set to hard-link symlinks.
31 confile=`echo "$scratchdir" | sed 's;/testtmp/itemize$;/config.h;'`
32 if egrep '^#define CAN_HARDLINK_SYMLINK 1' "$confile" >/dev/null; then
38 # Check if rsync can preserve time on symlinks
44 if $RSYNC --version | grep ", symtimes" >/dev/null; then
52 $RSYNC -iplr "$fromdir/" "$todir/" \
58 >f$all_plus bar/baz/rsync
60 >f$all_plus foo/config1
61 >f$all_plus foo/config2
63 cL$all_plus foo/sym -> ../bar/baz/rsync
65 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
67 # Ensure there are no accidental directory-time problems.
68 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
70 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
71 chmod 601 "$fromdir/foo/config2"
72 $RSYNC -iplrH "$fromdir/" "$todir/" \
75 >f..T.$dots bar/baz/rsync
76 >f..T.$dots foo/config1
77 >f.sTp$dots foo/config2
78 hf..T.$dots foo/extra => foo/config1
80 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
82 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
83 sleep 1 # For directory mod below to ensure time difference
86 ln -s ../bar/baz "$todir/foo/sym"
88 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
89 chmod 600 "$fromdir/foo/config2"
90 chmod 777 "$todir/bar/baz/rsync"
92 $RSYNC -iplrtc "$fromdir/" "$todir/" \
95 .f..tp$dots bar/baz/rsync
97 .f..t.$dots foo/config1
98 >fcstp$dots foo/config2
99 cLc$T.$dots foo/sym -> ../bar/baz/rsync
101 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
103 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
104 chmod 600 "$fromdir/foo/config2"
105 # Lack of -t is for unchanged hard-link stress-test!
106 $RSYNC -vvplrH "$fromdir/" "$todir/" \
109 cat <<EOT >"$chkfile"
110 bar/baz/rsync is uptodate
111 foo/config1 is uptodate
113 foo/extra is uptodate
116 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
118 chmod 747 "$todir/bar/baz/rsync"
119 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
120 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
123 cat <<EOT >"$chkfile"
127 .f...p$dots bar/baz/rsync
129 .f$allspace foo/config1
130 >f..t.$dots foo/config2
131 hf$allspace foo/extra
132 .L$allspace foo/sym -> ../bar/baz/rsync
134 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
136 chmod 757 "$todir/foo/config1"
137 touch "$todir/foo/config2"
138 $RSYNC -vplrtH "$fromdir/" "$todir/" \
141 cat <<EOT >"$chkfile"
144 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
146 chmod 757 "$todir/foo/config1"
147 touch "$todir/foo/config2"
148 $RSYNC -iplrtH "$fromdir/" "$todir/" \
150 cat <<EOT >"$chkfile"
151 .f...p$dots foo/config1
152 >f..t.$dots foo/config2
154 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
156 $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
159 case `tail -1 "$outfile"` in
162 L_sym_dots="cL$sym_dots"
163 is_uptodate='-> ../bar/baz/rsync'
164 echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
169 L_sym_dots=".L$allspace"
170 is_uptodate='is uptodate'
171 touch "$chkfile.extra"
174 cat <<EOT >"$chkfile"
178 cf$allspace bar/baz/rsync
180 cf$allspace foo/config1
181 cf$allspace foo/config2
182 hf$allspace foo/extra => foo/config1
183 cL$sym_dots foo/sym -> ../bar/baz/rsync
185 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
188 $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
190 cat - "$chkfile.extra" <<EOT >"$chkfile"
191 hf$allspace foo/extra => foo/config1
193 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
196 $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
199 cat <<EOT >"$chkfile"
203 bar/baz/rsync is uptodate
205 foo/config1 is uptodate
206 foo/config2 is uptodate
207 foo/extra => foo/config1
210 diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
213 $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
216 cat <<EOT >"$chkfile"
220 hf$allspace bar/baz/rsync
222 hf$allspace foo/config1
223 hf$allspace foo/config2
224 hf$allspace foo/extra => foo/config1
225 $L$sym_dots foo/sym -> ../bar/baz/rsync
227 diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
230 $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
232 cat - "$chkfile.extra" <<EOT >"$chkfile"
234 diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
237 $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
239 cat - "$chkfile.extra" <<EOT >"$chkfile"
241 diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
244 $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
247 cat <<EOT >"$chkfile"
251 bar/baz/rsync is uptodate
253 foo/config1 is uptodate
254 foo/config2 is uptodate
255 foo/extra is uptodate
258 diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
261 $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
264 cat <<EOT >"$chkfile"
268 .f$allspace bar/baz/rsync
270 .f$allspace foo/config1
271 .f$allspace foo/config2
272 .f$allspace foo/extra
273 $L_sym_dots foo/sym -> ../bar/baz/rsync
275 diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
278 $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
280 cat - "$chkfile.extra" <<EOT >"$chkfile"
282 diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
285 $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
288 cat <<EOT >"$chkfile"
292 bar/baz/rsync is uptodate
294 foo/config1 is uptodate
295 foo/config2 is uptodate
296 foo/extra is uptodate
299 diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
301 # The script would have aborted on error, so getting here means we've won.