3 # Copyright (C) 2005-2020 Wayne Davison
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 makepath "$fromdir/foo"
16 makepath "$fromdir/bar/baz"
17 cp_p "$srcdir/configure.ac" "$fromdir/foo/config1"
18 cp_p "$srcdir/config.sub" "$fromdir/foo/config2"
19 cp_p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
20 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
22 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
24 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
27 # Check if rsync is set to hard-link symlinks.
28 if $RSYNC --version | grep "[, ] hardlink-symlinks" >/dev/null; then
31 L_sym_dots=".L$allspace"
32 is_uptodate='is uptodate'
33 touch "$chkfile.extra"
37 L_sym_dots="cL$sym_dots"
38 is_uptodate='-> ../bar/baz/rsync'
39 echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
42 # Check if rsync can preserve time on symlinks
48 if $RSYNC --version | grep "[, ] symtimes" >/dev/null; then
56 checkdiff "$RSYNC -iplr '$fromdir/' '$todir/'" <<EOT
60 >f$all_plus bar/baz/rsync
62 >f$all_plus foo/config1
63 >f$all_plus foo/config2
65 cL$all_plus foo/sym -> ../bar/baz/rsync
68 # Ensure there are no accidental directory-time problems.
69 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
71 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
72 chmod 601 "$fromdir/foo/config2"
73 checkdiff "$RSYNC -iplrH '$fromdir/' '$todir/'" <<EOT
74 >f..T.$dots bar/baz/rsync
75 >f..T.$dots foo/config1
76 >f.sTp$dots foo/config2
77 hf..T.$dots foo/extra => foo/config1
80 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
81 cp_p "$srcdir/config.sub" "$fromdir/foo/config2"
82 sleep 1 # For directory mod below to ensure time difference
85 ln -s ../bar/baz "$todir/foo/sym"
87 chmod 600 "$fromdir/foo/config2"
88 chmod 777 "$todir/bar/baz/rsync"
90 checkdiff "$RSYNC -iplrtc '$fromdir/' '$todir/'" <<EOT
91 .f..tp$dots bar/baz/rsync
93 .f..t.$dots foo/config1
94 >fcstp$dots foo/config2
95 cLc$T.$dots foo/sym -> ../bar/baz/rsync
98 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
99 chmod 600 "$fromdir/foo/config2"
100 # Lack of -t is for unchanged hard-link stress-test!
101 checkdiff "$RSYNC -vvplrH '$fromdir/' '$todir/'" \
103 bar/baz/rsync is uptodate
104 foo/config1 is uptodate
105 foo/extra is uptodate
110 chmod 747 "$todir/bar/baz/rsync"
111 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
112 checkdiff "$RSYNC -ivvplrtH '$fromdir/' '$todir/'" \
117 .f...p$dots bar/baz/rsync
119 .f$allspace foo/config1
120 >f..t.$dots foo/config2
121 hf$allspace foo/extra
122 .L$allspace foo/sym -> ../bar/baz/rsync
125 chmod 757 "$todir/foo/config1"
126 touch "$todir/foo/config2"
127 checkdiff "$RSYNC -vplrtH '$fromdir/' '$todir/'" \
132 chmod 757 "$todir/foo/config1"
133 touch "$todir/foo/config2"
134 checkdiff "$RSYNC -iplrtH '$fromdir/' '$todir/'" <<EOT
135 .f...p$dots foo/config1
136 >f..t.$dots foo/config2
139 checkdiff "$RSYNC -ivvplrtH --copy-dest=../to '$fromdir/' '$to2dir/'" \
144 cf$allspace bar/baz/rsync
146 cf$allspace foo/config1
147 cf$allspace foo/config2
148 hf$allspace foo/extra => foo/config1
149 cL$sym_dots foo/sym -> ../bar/baz/rsync
153 cat - "$chkfile.extra" <<EOT >"$chkfile"
154 hf$allspace foo/extra => foo/config1
156 checkdiff2 "$RSYNC -iplrtH --copy-dest=../to '$fromdir/' '$to2dir/'"
159 checkdiff "$RSYNC -vvplrtH --copy-dest='$todir' '$fromdir/' '$to2dir/'" \
164 bar/baz/rsync is uptodate
166 foo/config1 is uptodate
167 foo/config2 is uptodate
169 foo/extra => foo/config1
173 checkdiff "$RSYNC -ivvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
178 hf$allspace bar/baz/rsync
180 hf$allspace foo/config1
181 hf$allspace foo/config2
182 hf$allspace foo/extra => foo/config1
183 $L$sym_dots foo/sym -> ../bar/baz/rsync
187 checkdiff "$RSYNC -iplrtH --dry-run --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
190 checkdiff "$RSYNC -iplrtH --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
193 checkdiff "$RSYNC -vvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
198 bar/baz/rsync is uptodate
200 foo/config1 is uptodate
201 foo/config2 is uptodate
202 foo/extra is uptodate
207 checkdiff "$RSYNC -ivvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
212 .f$allspace bar/baz/rsync
214 .f$allspace foo/config1
215 .f$allspace foo/config2
216 .f$allspace foo/extra
217 $L_sym_dots foo/sym -> ../bar/baz/rsync
221 checkdiff "$RSYNC -iplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" <"$chkfile.extra"
224 checkdiff "$RSYNC -vvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
229 bar/baz/rsync is uptodate
231 foo/config1 is uptodate
232 foo/config2 is uptodate
233 foo/extra is uptodate
237 # The script would have aborted on error, so getting here means we've won.