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