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