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