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