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