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