| 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 | itemregex='^[.<>ch][dfDL][c .+][s .+][tT .+][p .+][o .+][g .+][a .+] ' |
| 16 | |
| 17 | lddir="$tmpdir/ld" |
| 18 | |
| 19 | outfile="$scratchdir/rsync.out" |
| 20 | |
| 21 | makepath "$fromdir/foo" |
| 22 | makepath "$fromdir/bar/baz" |
| 23 | cp -p "$srcdir/config.h" "$fromdir/foo/config1" |
| 24 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
| 25 | cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync" |
| 26 | chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync" |
| 27 | umask 0 |
| 28 | ln -s ../bar/baz/rsync "$fromdir/foo/sym" |
| 29 | umask 022 |
| 30 | ln "$fromdir/foo/config1" "$fromdir/foo/extra" |
| 31 | |
| 32 | $RSYNC -iplr "$fromdir/" "$todir/" \ |
| 33 | | tee "$outfile" |
| 34 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 1 failed" |
| 35 | cd+++++++ bar/ |
| 36 | cd+++++++ bar/baz/ |
| 37 | >f+++++++ bar/baz/rsync |
| 38 | cd+++++++ foo/ |
| 39 | >f+++++++ foo/config1 |
| 40 | >f+++++++ foo/config2 |
| 41 | >f+++++++ foo/extra |
| 42 | cL+++++++ foo/sym -> ../bar/baz/rsync |
| 43 | EOT |
| 44 | |
| 45 | # Ensure there are no accidental directory-time problems. |
| 46 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 47 | |
| 48 | cp -p "$srcdir/config.h" "$fromdir/foo/config2" |
| 49 | chmod 601 "$fromdir/foo/config2" |
| 50 | $RSYNC -iplrH "$fromdir/" "$todir/" \ |
| 51 | | tee "$outfile" |
| 52 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 2 failed" |
| 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 | |
| 59 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 60 | sleep 1 # For directory mod below to ensure time difference |
| 61 | rm "$todir/foo/sym" |
| 62 | umask 0 |
| 63 | ln -s ../bar/baz "$todir/foo/sym" |
| 64 | umask 022 |
| 65 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
| 66 | chmod 600 "$fromdir/foo/config2" |
| 67 | chmod 777 "$todir/bar/baz/rsync" |
| 68 | |
| 69 | $RSYNC -iplrtc "$fromdir/" "$todir/" \ |
| 70 | | tee "$outfile" |
| 71 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 3 failed" |
| 72 | .f..tp... bar/baz/rsync |
| 73 | .d..t.... foo/ |
| 74 | .f..t.... foo/config1 |
| 75 | >fcstp... foo/config2 |
| 76 | cL..T.... foo/sym -> ../bar/baz/rsync |
| 77 | EOT |
| 78 | |
| 79 | cp -p "$srcdir/config.h" "$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 | | sed -e '1,/done$/d' -e '/--whole-file/d' -e '/total:/d' -e '/^$/,$d' \ |
| 84 | | tee "$outfile" |
| 85 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 4 failed" |
| 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 | |
| 93 | chmod 747 "$todir/bar/baz/rsync" |
| 94 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" |
| 95 | $RSYNC -ivvplrtH "$fromdir/" "$todir/" \ |
| 96 | | grep "$itemregex" \ |
| 97 | | tee "$outfile" |
| 98 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 5 failed" |
| 99 | .d ./ |
| 100 | .d bar/ |
| 101 | .d bar/baz/ |
| 102 | .f...p... bar/baz/rsync |
| 103 | .d foo/ |
| 104 | .f foo/config1 |
| 105 | >f..t.... foo/config2 |
| 106 | hf foo/extra |
| 107 | .L foo/sym -> ../bar/baz/rsync |
| 108 | EOT |
| 109 | |
| 110 | chmod 757 "$todir/foo/config1" |
| 111 | touch "$todir/foo/config2" |
| 112 | $RSYNC -vplrtH "$fromdir/" "$todir/" \ |
| 113 | | sed -e '/done$/d' -e '/^$/,$d' \ |
| 114 | | tee "$outfile" |
| 115 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 6 failed" |
| 116 | foo/config2 |
| 117 | EOT |
| 118 | |
| 119 | chmod 757 "$todir/foo/config1" |
| 120 | touch "$todir/foo/config2" |
| 121 | $RSYNC -iplrtH "$fromdir/" "$todir/" \ |
| 122 | | tee "$outfile" |
| 123 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 7 failed" |
| 124 | .f...p... foo/config1 |
| 125 | >f..t.... foo/config2 |
| 126 | EOT |
| 127 | |
| 128 | mv "$todir" "$lddir" |
| 129 | $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \ |
| 130 | | grep "$itemregex" \ |
| 131 | | tee "$outfile" |
| 132 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 8 failed" |
| 133 | .d..t.... ./ |
| 134 | cd+++++++ bar/ |
| 135 | cd+++++++ bar/baz/ |
| 136 | cf....... bar/baz/rsync |
| 137 | cd+++++++ foo/ |
| 138 | cf....... foo/config1 |
| 139 | cf....... foo/config2 |
| 140 | hf+++++++ foo/extra => foo/config1 |
| 141 | cL+++++++ foo/sym -> ../bar/baz/rsync |
| 142 | EOT |
| 143 | |
| 144 | rm -rf "$todir" |
| 145 | $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \ |
| 146 | | tee "$outfile" |
| 147 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 9 failed" |
| 148 | .d..t.... ./ |
| 149 | cd+++++++ bar/ |
| 150 | cd+++++++ bar/baz/ |
| 151 | cd+++++++ foo/ |
| 152 | hf+++++++ foo/extra => foo/config1 |
| 153 | cL+++++++ foo/sym -> ../bar/baz/rsync |
| 154 | EOT |
| 155 | |
| 156 | # The script would have aborted on error, so getting here means we've won. |
| 157 | exit 0 |