| 1 | #! /bin/sh |
| 2 | |
| 3 | # Copyright (C) 2005 by Wayne Davison <wayned@samba.org> |
| 4 | |
| 5 | # This program is distributable under the terms of the GNU GPL (see |
| 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 | |
| 13 | case "$RSYNC" in |
| 14 | *protocol=29*) |
| 15 | sed_cmd='/_P30_/d; s/_P29_//' |
| 16 | ;; |
| 17 | *) |
| 18 | sed_cmd='/_P29_/d; s/_P30_//' |
| 19 | ;; |
| 20 | esac |
| 21 | |
| 22 | to2dir="$tmpdir/to2" |
| 23 | |
| 24 | chkfile="$scratchdir/rsync.chk" |
| 25 | outfile="$scratchdir/rsync.out" |
| 26 | |
| 27 | makepath "$fromdir/foo" |
| 28 | makepath "$fromdir/bar/baz" |
| 29 | cp -p "$srcdir/configure.in" "$fromdir/foo/config1" |
| 30 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
| 31 | cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync" |
| 32 | chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync" |
| 33 | umask 0 |
| 34 | ln -s ../bar/baz/rsync "$fromdir/foo/sym" |
| 35 | umask 022 |
| 36 | ln "$fromdir/foo/config1" "$fromdir/foo/extra" |
| 37 | |
| 38 | # Check if the OS can hard-link symlinks or not |
| 39 | ln -s no-such-dir "$to2dir" |
| 40 | if ln "$to2dir" "$to2dir.test" 2>/dev/null; then |
| 41 | L=hL |
| 42 | else |
| 43 | L=cL |
| 44 | fi |
| 45 | rm -f "$to2dir" "$to2dir.test" |
| 46 | |
| 47 | $RSYNC -iplr "$fromdir/" "$todir/" \ |
| 48 | | tee "$outfile" |
| 49 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 50 | cd+++++++ ./ |
| 51 | cd+++++++ bar/ |
| 52 | cd+++++++ foo/_P30_ |
| 53 | cd+++++++ bar/baz/ |
| 54 | >f+++++++ bar/baz/rsync |
| 55 | cd+++++++ foo/_P29_ |
| 56 | >f+++++++ foo/config1 |
| 57 | >f+++++++ foo/config2 |
| 58 | >f+++++++ foo/extra |
| 59 | cL+++++++ foo/sym -> ../bar/baz/rsync |
| 60 | EOT |
| 61 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed" |
| 62 | |
| 63 | # Ensure there are no accidental directory-time problems. |
| 64 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 65 | |
| 66 | cp -p "$srcdir/configure.in" "$fromdir/foo/config2" |
| 67 | chmod 601 "$fromdir/foo/config2" |
| 68 | $RSYNC -iplrH "$fromdir/" "$todir/" \ |
| 69 | | tee "$outfile" |
| 70 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 71 | >f..T.... bar/baz/rsync |
| 72 | >f..T.... foo/config1 |
| 73 | >f.sTp... foo/config2 |
| 74 | hf..T.... foo/extra => foo/config1 |
| 75 | EOT |
| 76 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed" |
| 77 | |
| 78 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 79 | sleep 1 # For directory mod below to ensure time difference |
| 80 | rm "$todir/foo/sym" |
| 81 | umask 0 |
| 82 | ln -s ../bar/baz "$todir/foo/sym" |
| 83 | umask 022 |
| 84 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
| 85 | chmod 600 "$fromdir/foo/config2" |
| 86 | chmod 777 "$todir/bar/baz/rsync" |
| 87 | |
| 88 | $RSYNC -iplrtc "$fromdir/" "$todir/" \ |
| 89 | | tee "$outfile" |
| 90 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 91 | .d..t.... foo/_P30_ |
| 92 | .f..tp... bar/baz/rsync |
| 93 | .d..t.... foo/_P29_ |
| 94 | .f..t.... foo/config1 |
| 95 | >fcstp... foo/config2 |
| 96 | cL..T.... foo/sym -> ../bar/baz/rsync |
| 97 | EOT |
| 98 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed" |
| 99 | |
| 100 | cp -p "$srcdir/configure.in" "$fromdir/foo/config2" |
| 101 | chmod 600 "$fromdir/foo/config2" |
| 102 | # Lack of -t is for unchanged hard-link stress-test! |
| 103 | $RSYNC -vvplrH "$fromdir/" "$todir/" \ |
| 104 | | tee "$outfile" |
| 105 | filter_outfile |
| 106 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 107 | bar/baz/rsync is uptodate |
| 108 | foo/config1 is uptodate |
| 109 | foo/config2 |
| 110 | foo/extra is uptodate |
| 111 | foo/sym is uptodate |
| 112 | EOT |
| 113 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed" |
| 114 | |
| 115 | chmod 747 "$todir/bar/baz/rsync" |
| 116 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 117 | $RSYNC -ivvplrtH "$fromdir/" "$todir/" \ |
| 118 | | tee "$outfile" |
| 119 | filter_outfile |
| 120 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 121 | .d ./ |
| 122 | .d bar/ |
| 123 | .d bar/baz/ |
| 124 | .f...p... bar/baz/rsync |
| 125 | .d foo/ |
| 126 | .f foo/config1 |
| 127 | >f..t.... foo/config2 |
| 128 | hf foo/extra |
| 129 | .L foo/sym -> ../bar/baz/rsync |
| 130 | EOT |
| 131 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed" |
| 132 | |
| 133 | chmod 757 "$todir/foo/config1" |
| 134 | touch "$todir/foo/config2" |
| 135 | $RSYNC -vplrtH "$fromdir/" "$todir/" \ |
| 136 | | tee "$outfile" |
| 137 | filter_outfile |
| 138 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 139 | foo/config2 |
| 140 | EOT |
| 141 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed" |
| 142 | |
| 143 | chmod 757 "$todir/foo/config1" |
| 144 | touch "$todir/foo/config2" |
| 145 | $RSYNC -iplrtH "$fromdir/" "$todir/" \ |
| 146 | | tee "$outfile" |
| 147 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 148 | .f...p... foo/config1 |
| 149 | >f..t.... foo/config2 |
| 150 | EOT |
| 151 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed" |
| 152 | |
| 153 | $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \ |
| 154 | | tee "$outfile" |
| 155 | filter_outfile |
| 156 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 157 | cd ./ |
| 158 | cd bar/ |
| 159 | cd bar/baz/ |
| 160 | cf bar/baz/rsync |
| 161 | cd foo/ |
| 162 | cf foo/config1 |
| 163 | cf foo/config2 |
| 164 | hf foo/extra => foo/config1 |
| 165 | cL foo/sym -> ../bar/baz/rsync |
| 166 | EOT |
| 167 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed" |
| 168 | |
| 169 | rm -rf "$to2dir" |
| 170 | $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \ |
| 171 | | tee "$outfile" |
| 172 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 173 | hf foo/extra => foo/config1 |
| 174 | EOT |
| 175 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed" |
| 176 | |
| 177 | rm -rf "$to2dir" |
| 178 | $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 179 | | tee "$outfile" |
| 180 | filter_outfile |
| 181 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 182 | ./ is uptodate |
| 183 | bar/ is uptodate |
| 184 | bar/baz/ is uptodate |
| 185 | bar/baz/rsync is uptodate |
| 186 | foo/ is uptodate |
| 187 | foo/config1 is uptodate |
| 188 | foo/config2 is uptodate |
| 189 | foo/extra => foo/config1 |
| 190 | foo/sym is uptodate |
| 191 | EOT |
| 192 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed" |
| 193 | |
| 194 | rm -rf "$to2dir" |
| 195 | $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 196 | | tee "$outfile" |
| 197 | filter_outfile |
| 198 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 199 | cd ./ |
| 200 | cd bar/ |
| 201 | cd bar/baz/ |
| 202 | hf bar/baz/rsync |
| 203 | cd foo/ |
| 204 | hf foo/config1 |
| 205 | hf foo/config2 |
| 206 | hf foo/extra => foo/config1 |
| 207 | $L foo/sym -> ../bar/baz/rsync |
| 208 | EOT |
| 209 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed" |
| 210 | |
| 211 | rm -rf "$to2dir" |
| 212 | $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \ |
| 213 | | tee "$outfile" |
| 214 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 215 | EOT |
| 216 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed" |
| 217 | |
| 218 | rm -rf "$to2dir" |
| 219 | $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \ |
| 220 | | tee "$outfile" |
| 221 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 222 | EOT |
| 223 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed" |
| 224 | |
| 225 | rm -rf "$to2dir" |
| 226 | $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 227 | | tee "$outfile" |
| 228 | filter_outfile |
| 229 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 230 | ./ is uptodate |
| 231 | bar/ is uptodate |
| 232 | bar/baz/ is uptodate |
| 233 | bar/baz/rsync is uptodate |
| 234 | foo/ is uptodate |
| 235 | foo/config1 is uptodate |
| 236 | foo/config2 is uptodate |
| 237 | foo/extra is uptodate |
| 238 | foo/sym is uptodate |
| 239 | EOT |
| 240 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed" |
| 241 | |
| 242 | rm -rf "$to2dir" |
| 243 | $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 244 | | tee "$outfile" |
| 245 | filter_outfile |
| 246 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 247 | cd ./ |
| 248 | cd bar/ |
| 249 | cd bar/baz/ |
| 250 | .f bar/baz/rsync |
| 251 | cd foo/ |
| 252 | .f foo/config1 |
| 253 | .f foo/config2 |
| 254 | .f foo/extra |
| 255 | .L foo/sym -> ../bar/baz/rsync |
| 256 | EOT |
| 257 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed" |
| 258 | |
| 259 | rm -rf "$to2dir" |
| 260 | $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 261 | | tee "$outfile" |
| 262 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 263 | EOT |
| 264 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed" |
| 265 | |
| 266 | rm -rf "$to2dir" |
| 267 | $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \ |
| 268 | | tee "$outfile" |
| 269 | filter_outfile |
| 270 | sed -e "$sed_cmd" <<EOT >"$chkfile" |
| 271 | ./ is uptodate |
| 272 | bar/ is uptodate |
| 273 | bar/baz/ is uptodate |
| 274 | bar/baz/rsync is uptodate |
| 275 | foo/ is uptodate |
| 276 | foo/config1 is uptodate |
| 277 | foo/config2 is uptodate |
| 278 | foo/extra is uptodate |
| 279 | foo/sym is uptodate |
| 280 | EOT |
| 281 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed" |
| 282 | |
| 283 | # The script would have aborted on error, so getting here means we've won. |
| 284 | exit 0 |