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