Fixed some itemized logging failures:
[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 rm -f "$to2dir"
29
30 # Check if rsync is set to hard-link symlinks.
31 confile=`echo "$scratchdir" | sed 's;/testtmp/itemize$;/config.h;'`
32 if egrep '^#define CAN_HARDLINK_SYMLINK 1' "$confile" >/dev/null; then
33     L=hL
34 else
35     L=cL
36 fi
37
38 # Check if rsync can preserve time on symlinks
39 case "$RSYNC" in
40 *protocol=2*)
41     T=.T
42     ;;
43 *)
44     if $RSYNC --version | grep ", symtimes" >/dev/null; then
45         T=.t
46     else
47         T=.T
48     fi
49     ;;
50 esac
51
52 $RSYNC -iplr "$fromdir/" "$todir/" \
53     | tee "$outfile"
54 cat <<EOT >"$chkfile"
55 cd$all_plus ./
56 cd$all_plus bar/
57 cd$all_plus bar/baz/
58 >f$all_plus bar/baz/rsync
59 cd$all_plus foo/
60 >f$all_plus foo/config1
61 >f$all_plus foo/config2
62 >f$all_plus foo/extra
63 cL$all_plus foo/sym -> ../bar/baz/rsync
64 EOT
65 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
66
67 # Ensure there are no accidental directory-time problems.
68 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
69
70 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
71 chmod 601 "$fromdir/foo/config2"
72 $RSYNC -iplrH "$fromdir/" "$todir/" \
73     | tee "$outfile"
74 cat <<EOT >"$chkfile"
75 >f..T.$dots bar/baz/rsync
76 >f..T.$dots foo/config1
77 >f.sTp$dots foo/config2
78 hf..T.$dots foo/extra => foo/config1
79 EOT
80 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
81
82 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
83 sleep 1 # For directory mod below to ensure time difference
84 rm "$todir/foo/sym"
85 umask 0
86 ln -s ../bar/baz "$todir/foo/sym"
87 umask 022
88 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
89 chmod 600 "$fromdir/foo/config2"
90 chmod 777 "$todir/bar/baz/rsync"
91
92 $RSYNC -iplrtc "$fromdir/" "$todir/" \
93     | tee "$outfile"
94 cat <<EOT >"$chkfile"
95 .f..tp$dots bar/baz/rsync
96 .d..t.$dots foo/
97 .f..t.$dots foo/config1
98 >fcstp$dots foo/config2
99 cLc$T.$dots foo/sym -> ../bar/baz/rsync
100 EOT
101 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
102
103 cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
104 chmod 600 "$fromdir/foo/config2"
105 # Lack of -t is for unchanged hard-link stress-test!
106 $RSYNC -vvplrH "$fromdir/" "$todir/" \
107     | tee "$outfile"
108 filter_outfile
109 cat <<EOT >"$chkfile"
110 bar/baz/rsync is uptodate
111 foo/config1 is uptodate
112 foo/config2
113 foo/extra is uptodate
114 foo/sym is uptodate
115 EOT
116 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
117
118 chmod 747 "$todir/bar/baz/rsync"
119 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
120 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
121     | tee "$outfile"
122 filter_outfile
123 cat <<EOT >"$chkfile"
124 .d$allspace ./
125 .d$allspace bar/
126 .d$allspace bar/baz/
127 .f...p$dots bar/baz/rsync
128 .d$allspace foo/
129 .f$allspace foo/config1
130 >f..t.$dots foo/config2
131 hf$allspace foo/extra
132 .L$allspace foo/sym -> ../bar/baz/rsync
133 EOT
134 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
135
136 chmod 757 "$todir/foo/config1"
137 touch "$todir/foo/config2"
138 $RSYNC -vplrtH "$fromdir/" "$todir/" \
139     | tee "$outfile"
140 filter_outfile
141 cat <<EOT >"$chkfile"
142 foo/config2
143 EOT
144 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
145
146 chmod 757 "$todir/foo/config1"
147 touch "$todir/foo/config2"
148 $RSYNC -iplrtH "$fromdir/" "$todir/" \
149     | tee "$outfile"
150 cat <<EOT >"$chkfile"
151 .f...p$dots foo/config1
152 >f..t.$dots foo/config2
153 EOT
154 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
155
156 $RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
157     | tee "$outfile"
158 filter_outfile
159 case `tail -1 "$outfile"` in
160 cLc.t*)
161     sym_dots="c.t.$dots"
162     L_sym_dots="cL$sym_dots"
163     is_uptodate='-> ../bar/baz/rsync'
164     echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
165     L=cL
166     ;;
167 *)
168     sym_dots="$allspace"
169     L_sym_dots=".L$allspace"
170     is_uptodate='is uptodate'
171     touch "$chkfile.extra"
172     ;;
173 esac
174 cat <<EOT >"$chkfile"
175 cd$allspace ./
176 cd$allspace bar/
177 cd$allspace bar/baz/
178 cf$allspace bar/baz/rsync
179 cd$allspace foo/
180 cf$allspace foo/config1
181 cf$allspace foo/config2
182 hf$allspace foo/extra => foo/config1
183 cL$sym_dots foo/sym -> ../bar/baz/rsync
184 EOT
185 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
186
187 rm -rf "$to2dir"
188 $RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
189     | tee "$outfile"
190 cat - "$chkfile.extra" <<EOT >"$chkfile"
191 hf$allspace foo/extra => foo/config1
192 EOT
193 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
194
195 rm -rf "$to2dir"
196 $RSYNC -vvplrtH --copy-dest="$todir" "$fromdir/" "$to2dir/" \
197     | tee "$outfile"
198 filter_outfile
199 cat <<EOT >"$chkfile"
200 ./ is uptodate
201 bar/ is uptodate
202 bar/baz/ is uptodate
203 bar/baz/rsync is uptodate
204 foo/ is uptodate
205 foo/config1 is uptodate
206 foo/config2 is uptodate
207 foo/extra => foo/config1
208 foo/sym $is_uptodate
209 EOT
210 diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
211
212 rm -rf "$to2dir"
213 $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
214     | tee "$outfile"
215 filter_outfile
216 cat <<EOT >"$chkfile"
217 cd$allspace ./
218 cd$allspace bar/
219 cd$allspace bar/baz/
220 hf$allspace bar/baz/rsync
221 cd$allspace foo/
222 hf$allspace foo/config1
223 hf$allspace foo/config2
224 hf$allspace foo/extra => foo/config1
225 $L$sym_dots foo/sym -> ../bar/baz/rsync
226 EOT
227 diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
228
229 rm -rf "$to2dir"
230 $RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
231     | tee "$outfile"
232 cat - "$chkfile.extra" <<EOT >"$chkfile"
233 EOT
234 diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
235
236 rm -rf "$to2dir"
237 $RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
238     | tee "$outfile"
239 cat - "$chkfile.extra" <<EOT >"$chkfile"
240 EOT
241 diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
242
243 rm -rf "$to2dir"
244 $RSYNC -vvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
245     | tee "$outfile"
246 filter_outfile
247 cat <<EOT >"$chkfile"
248 ./ is uptodate
249 bar/ is uptodate
250 bar/baz/ is uptodate
251 bar/baz/rsync is uptodate
252 foo/ is uptodate
253 foo/config1 is uptodate
254 foo/config2 is uptodate
255 foo/extra is uptodate
256 foo/sym $is_uptodate
257 EOT
258 diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
259
260 rm -rf "$to2dir"
261 $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
262     | tee "$outfile"
263 filter_outfile
264 cat <<EOT >"$chkfile"
265 cd$allspace ./
266 cd$allspace bar/
267 cd$allspace bar/baz/
268 .f$allspace bar/baz/rsync
269 cd$allspace foo/
270 .f$allspace foo/config1
271 .f$allspace foo/config2
272 .f$allspace foo/extra
273 $L_sym_dots foo/sym -> ../bar/baz/rsync
274 EOT
275 diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
276
277 rm -rf "$to2dir"
278 $RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
279     | tee "$outfile"
280 cat - "$chkfile.extra" <<EOT >"$chkfile"
281 EOT
282 diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
283
284 rm -rf "$to2dir"
285 $RSYNC -vvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
286     | tee "$outfile"
287 filter_outfile
288 cat <<EOT >"$chkfile"
289 ./ is uptodate
290 bar/ is uptodate
291 bar/baz/ is uptodate
292 bar/baz/rsync is uptodate
293 foo/ is uptodate
294 foo/config1 is uptodate
295 foo/config2 is uptodate
296 foo/extra is uptodate
297 foo/sym $is_uptodate
298 EOT
299 diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
300
301 # The script would have aborted on error, so getting here means we've won.
302 exit 0