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 | ||
5794112a WD |
15 | lddir="$tmpdir/ld" |
16 | ||
4f3be36e | 17 | chkfile="$scratchdir/rsync.chk" |
5794112a WD |
18 | outfile="$scratchdir/rsync.out" |
19 | ||
4f3be36e | 20 | filter_outfile() { |
6a12f0d6 WD |
21 | sed -e '/^building file list /d' \ |
22 | -e '/^created directory /d' \ | |
23 | -e '/^done$/d' \ | |
24 | -e '/ --whole-file$/d' \ | |
25 | -e '/^total: /d' \ | |
4f3be36e WD |
26 | -e '/^$/,$d' \ |
27 | <"$outfile" >"$outfile.new" | |
28 | mv "$outfile.new" "$outfile" | |
29 | } | |
30 | ||
5794112a WD |
31 | makepath "$fromdir/foo" |
32 | makepath "$fromdir/bar/baz" | |
33 | cp -p "$srcdir/config.h" "$fromdir/foo/config1" | |
34 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" | |
35 | cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync" | |
e73ad2be | 36 | chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync" |
87a57a30 | 37 | umask 0 |
5794112a | 38 | ln -s ../bar/baz/rsync "$fromdir/foo/sym" |
87a57a30 | 39 | umask 022 |
5794112a WD |
40 | ln "$fromdir/foo/config1" "$fromdir/foo/extra" |
41 | ||
42 | $RSYNC -iplr "$fromdir/" "$todir/" \ | |
43 | | tee "$outfile" | |
4f3be36e | 44 | cat <<EOT >"$chkfile" |
5794112a WD |
45 | cd+++++++ bar/ |
46 | cd+++++++ bar/baz/ | |
47 | >f+++++++ bar/baz/rsync | |
48 | cd+++++++ foo/ | |
49 | >f+++++++ foo/config1 | |
50 | >f+++++++ foo/config2 | |
51 | >f+++++++ foo/extra | |
52 | cL+++++++ foo/sym -> ../bar/baz/rsync | |
53 | EOT | |
4f3be36e | 54 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed" |
5794112a WD |
55 | |
56 | # Ensure there are no accidental directory-time problems. | |
57 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
58 | ||
59 | cp -p "$srcdir/config.h" "$fromdir/foo/config2" | |
e73ad2be | 60 | chmod 601 "$fromdir/foo/config2" |
5794112a WD |
61 | $RSYNC -iplrH "$fromdir/" "$todir/" \ |
62 | | tee "$outfile" | |
4f3be36e | 63 | cat <<EOT >"$chkfile" |
5794112a WD |
64 | >f..T.... bar/baz/rsync |
65 | >f..T.... foo/config1 | |
e73ad2be | 66 | >f.sTp... foo/config2 |
5794112a WD |
67 | hf..T.... foo/extra => foo/config1 |
68 | EOT | |
4f3be36e | 69 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed" |
5794112a WD |
70 | |
71 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
72 | sleep 1 # For directory mod below to ensure time difference | |
73 | rm "$todir/foo/sym" | |
a3dcb790 | 74 | umask 0 |
5794112a | 75 | ln -s ../bar/baz "$todir/foo/sym" |
a3dcb790 | 76 | umask 022 |
5794112a | 77 | cp -p "$srcdir/config.h.in" "$fromdir/foo/config2" |
e73ad2be | 78 | chmod 600 "$fromdir/foo/config2" |
5794112a WD |
79 | chmod 777 "$todir/bar/baz/rsync" |
80 | ||
81 | $RSYNC -iplrtc "$fromdir/" "$todir/" \ | |
82 | | tee "$outfile" | |
4f3be36e | 83 | cat <<EOT >"$chkfile" |
5794112a WD |
84 | .f..tp... bar/baz/rsync |
85 | .d..t.... foo/ | |
86 | .f..t.... foo/config1 | |
e73ad2be | 87 | >fcstp... foo/config2 |
5794112a WD |
88 | cL..T.... foo/sym -> ../bar/baz/rsync |
89 | EOT | |
4f3be36e | 90 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed" |
5794112a WD |
91 | |
92 | cp -p "$srcdir/config.h" "$fromdir/foo/config2" | |
e73ad2be | 93 | chmod 600 "$fromdir/foo/config2" |
5794112a WD |
94 | # Lack of -t is for unchanged hard-link stress-test! |
95 | $RSYNC -vvplrH "$fromdir/" "$todir/" \ | |
5794112a | 96 | | tee "$outfile" |
4f3be36e | 97 | cat <<EOT >"$chkfile" |
5794112a WD |
98 | bar/baz/rsync is uptodate |
99 | foo/config1 is uptodate | |
100 | foo/config2 | |
101 | "foo/extra" is a hard link | |
102 | foo/sym is uptodate | |
103 | EOT | |
4f3be36e WD |
104 | filter_outfile |
105 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed" | |
5794112a WD |
106 | |
107 | chmod 747 "$todir/bar/baz/rsync" | |
108 | $RSYNC -a -f '-! */' "$fromdir/" "$todir" | |
109 | $RSYNC -ivvplrtH "$fromdir/" "$todir/" \ | |
5794112a | 110 | | tee "$outfile" |
4f3be36e | 111 | cat <<EOT >"$chkfile" |
5794112a WD |
112 | .d ./ |
113 | .d bar/ | |
114 | .d bar/baz/ | |
115 | .f...p... bar/baz/rsync | |
116 | .d foo/ | |
117 | .f foo/config1 | |
118 | >f..t.... foo/config2 | |
119 | hf foo/extra | |
120 | .L foo/sym -> ../bar/baz/rsync | |
121 | EOT | |
4f3be36e WD |
122 | filter_outfile |
123 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed" | |
5794112a WD |
124 | |
125 | chmod 757 "$todir/foo/config1" | |
126 | touch "$todir/foo/config2" | |
127 | $RSYNC -vplrtH "$fromdir/" "$todir/" \ | |
5794112a | 128 | | tee "$outfile" |
4f3be36e | 129 | cat <<EOT >"$chkfile" |
5794112a WD |
130 | foo/config2 |
131 | EOT | |
4f3be36e WD |
132 | filter_outfile |
133 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed" | |
5794112a WD |
134 | |
135 | chmod 757 "$todir/foo/config1" | |
136 | touch "$todir/foo/config2" | |
137 | $RSYNC -iplrtH "$fromdir/" "$todir/" \ | |
138 | | tee "$outfile" | |
4f3be36e | 139 | cat <<EOT >"$chkfile" |
5794112a WD |
140 | .f...p... foo/config1 |
141 | >f..t.... foo/config2 | |
142 | EOT | |
4f3be36e | 143 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed" |
5794112a WD |
144 | |
145 | mv "$todir" "$lddir" | |
146 | $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \ | |
5794112a | 147 | | tee "$outfile" |
4f3be36e | 148 | cat <<EOT >"$chkfile" |
5794112a WD |
149 | .d..t.... ./ |
150 | cd+++++++ bar/ | |
151 | cd+++++++ bar/baz/ | |
152 | cf....... bar/baz/rsync | |
153 | cd+++++++ foo/ | |
154 | cf....... foo/config1 | |
155 | cf....... foo/config2 | |
156 | hf+++++++ foo/extra => foo/config1 | |
157 | cL+++++++ foo/sym -> ../bar/baz/rsync | |
158 | EOT | |
4f3be36e WD |
159 | filter_outfile |
160 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed" | |
5794112a WD |
161 | |
162 | rm -rf "$todir" | |
163 | $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \ | |
164 | | tee "$outfile" | |
4f3be36e | 165 | cat <<EOT >"$chkfile" |
5794112a WD |
166 | .d..t.... ./ |
167 | cd+++++++ bar/ | |
168 | cd+++++++ bar/baz/ | |
169 | cd+++++++ foo/ | |
170 | hf+++++++ foo/extra => foo/config1 | |
171 | cL+++++++ foo/sym -> ../bar/baz/rsync | |
172 | EOT | |
4f3be36e | 173 | diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed" |
5794112a WD |
174 | |
175 | # The script would have aborted on error, so getting here means we've won. | |
176 | exit 0 |