Commit | Line | Data |
---|---|---|
5794112a WD |
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 | ln -s ../bar/baz/rsync "$fromdir/foo/sym" | |
27 | ln "$fromdir/foo/config1" "$fromdir/foo/extra" | |
28 | ||
29 | $RSYNC -iplr "$fromdir/" "$todir/" \ | |
30 | | tee "$outfile" | |
31 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 1 failed" | |
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 | ||
42 | # Ensure there are no accidental directory-time problems. | |
43 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
44 | ||
45 | cp -p "$srcdir/config.h" "$fromdir/foo/config2" | |
46 | $RSYNC -iplrH "$fromdir/" "$todir/" \ | |
47 | | tee "$outfile" | |
48 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 2 failed" | |
49 | >f..T.... bar/baz/rsync | |
50 | >f..T.... foo/config1 | |
51 | >f.sT.... foo/config2 | |
52 | hf..T.... foo/extra => foo/config1 | |
53 | EOT | |
54 | ||
55 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
56 | sleep 1 # For directory mod below to ensure time difference | |
57 | rm "$todir/foo/sym" | |
58 | ln -s ../bar/baz "$todir/foo/sym" | |
59 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" | |
60 | chmod 777 "$todir/bar/baz/rsync" | |
61 | ||
62 | $RSYNC -iplrtc "$fromdir/" "$todir/" \ | |
63 | | tee "$outfile" | |
64 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 3 failed" | |
65 | .f..tp... bar/baz/rsync | |
66 | .d..t.... foo/ | |
67 | .f..t.... foo/config1 | |
68 | >fcst.... foo/config2 | |
69 | cL..T.... foo/sym -> ../bar/baz/rsync | |
70 | EOT | |
71 | ||
72 | cp -p "$srcdir/config.h" "$fromdir/foo/config2" | |
73 | # Lack of -t is for unchanged hard-link stress-test! | |
74 | $RSYNC -vvplrH "$fromdir/" "$todir/" \ | |
75 | | sed -e '0,/done$/d' -e '/--whole-file/d' -e '/total:/d' -e '/^$/,$d' \ | |
76 | | tee "$outfile" | |
77 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 4 failed" | |
78 | bar/baz/rsync is uptodate | |
79 | foo/config1 is uptodate | |
80 | foo/config2 | |
81 | "foo/extra" is a hard link | |
82 | foo/sym is uptodate | |
83 | EOT | |
84 | ||
85 | chmod 747 "$todir/bar/baz/rsync" | |
86 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
87 | $RSYNC -ivvplrtH "$fromdir/" "$todir/" \ | |
88 | | grep "$itemregex" \ | |
89 | | tee "$outfile" | |
90 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 5 failed" | |
91 | .d ./ | |
92 | .d bar/ | |
93 | .d bar/baz/ | |
94 | .f...p... bar/baz/rsync | |
95 | .d foo/ | |
96 | .f foo/config1 | |
97 | >f..t.... foo/config2 | |
98 | hf foo/extra | |
99 | .L foo/sym -> ../bar/baz/rsync | |
100 | EOT | |
101 | ||
102 | chmod 757 "$todir/foo/config1" | |
103 | touch "$todir/foo/config2" | |
104 | $RSYNC -vplrtH "$fromdir/" "$todir/" \ | |
105 | | sed -e '0,/done$/d' -e '/^$/,$d' \ | |
106 | | tee "$outfile" | |
107 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 6 failed" | |
108 | foo/config2 | |
109 | EOT | |
110 | ||
111 | chmod 757 "$todir/foo/config1" | |
112 | touch "$todir/foo/config2" | |
113 | $RSYNC -iplrtH "$fromdir/" "$todir/" \ | |
114 | | tee "$outfile" | |
115 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 7 failed" | |
116 | .f...p... foo/config1 | |
117 | >f..t.... foo/config2 | |
118 | EOT | |
119 | ||
120 | mv "$todir" "$lddir" | |
121 | $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \ | |
122 | | grep "$itemregex" \ | |
123 | | tee "$outfile" | |
124 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 8 failed" | |
125 | .d..t.... ./ | |
126 | cd+++++++ bar/ | |
127 | cd+++++++ bar/baz/ | |
128 | cf....... bar/baz/rsync | |
129 | cd+++++++ foo/ | |
130 | cf....... foo/config1 | |
131 | cf....... foo/config2 | |
132 | hf+++++++ foo/extra => foo/config1 | |
133 | cL+++++++ foo/sym -> ../bar/baz/rsync | |
134 | EOT | |
135 | ||
136 | rm -rf "$todir" | |
137 | $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \ | |
138 | | tee "$outfile" | |
139 | cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 9 failed" | |
140 | .d..t.... ./ | |
141 | cd+++++++ bar/ | |
142 | cd+++++++ bar/baz/ | |
143 | cd+++++++ foo/ | |
144 | hf+++++++ foo/extra => foo/config1 | |
145 | cL+++++++ foo/sym -> ../bar/baz/rsync | |
146 | EOT | |
147 | ||
148 | # The script would have aborted on error, so getting here means we've won. | |
149 | exit 0 |