Changed two more references to "st" to "real_st" in the dir-handling
[rsync/rsync.git] / testsuite / itemize.test
CommitLineData
5794112a
WD
1#! /bin/sh
2
3# Copyright (C) 2005 by Wayne Davison <wayned@samba.org>
4
c8d19f90 5# This program is distributable under the terms of the GNU GPL (see
5794112a
WD
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
5794112a
WD
13lddir="$tmpdir/ld"
14
4f3be36e 15chkfile="$scratchdir/rsync.chk"
5794112a
WD
16outfile="$scratchdir/rsync.out"
17
18makepath "$fromdir/foo"
19makepath "$fromdir/bar/baz"
309a5be8 20cp -p "$srcdir/configure.in" "$fromdir/foo/config1"
5794112a
WD
21cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
22cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
e73ad2be 23chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
87a57a30 24umask 0
5794112a 25ln -s ../bar/baz/rsync "$fromdir/foo/sym"
87a57a30 26umask 022
5794112a
WD
27ln "$fromdir/foo/config1" "$fromdir/foo/extra"
28
3b8ed842
WD
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
5794112a
WD
33$RSYNC -iplr "$fromdir/" "$todir/" \
34 | tee "$outfile"
4f3be36e 35cat <<EOT >"$chkfile"
418b6a27 36cd+++++++ ./
503f1634
WD
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
5794112a 45EOT
4f3be36e 46diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
5794112a
WD
47
48# Ensure there are no accidental directory-time problems.
49$RSYNC -a -f '-! */' "$fromdir/" "$todir"
50
309a5be8 51cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
e73ad2be 52chmod 601 "$fromdir/foo/config2"
5794112a
WD
53$RSYNC -iplrH "$fromdir/" "$todir/" \
54 | tee "$outfile"
4f3be36e 55cat <<EOT >"$chkfile"
503f1634
WD
56>f..T.... bar/baz/rsync
57>f..T.... foo/config1
58>f.sTp... foo/config2
59hf..T.... foo/extra => foo/config1
5794112a 60EOT
4f3be36e 61diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
5794112a
WD
62
63$RSYNC -a -f '-! */' "$fromdir/" "$todir"
64sleep 1 # For directory mod below to ensure time difference
65rm "$todir/foo/sym"
a3dcb790 66umask 0
5794112a 67ln -s ../bar/baz "$todir/foo/sym"
a3dcb790 68umask 022
5794112a 69cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
e73ad2be 70chmod 600 "$fromdir/foo/config2"
5794112a
WD
71chmod 777 "$todir/bar/baz/rsync"
72
73$RSYNC -iplrtc "$fromdir/" "$todir/" \
74 | tee "$outfile"
4f3be36e 75cat <<EOT >"$chkfile"
503f1634
WD
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
5794112a 81EOT
4f3be36e 82diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
5794112a 83
309a5be8 84cp -p "$srcdir/configure.in" "$fromdir/foo/config2"
e73ad2be 85chmod 600 "$fromdir/foo/config2"
5794112a
WD
86# Lack of -t is for unchanged hard-link stress-test!
87$RSYNC -vvplrH "$fromdir/" "$todir/" \
5794112a 88 | tee "$outfile"
8af1bc90 89filter_outfile
4f3be36e 90cat <<EOT >"$chkfile"
5794112a
WD
91bar/baz/rsync is uptodate
92foo/config1 is uptodate
93foo/config2
94"foo/extra" is a hard link
95foo/sym is uptodate
96EOT
4f3be36e 97diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
5794112a
WD
98
99chmod 747 "$todir/bar/baz/rsync"
100$RSYNC -a -f '-! */' "$fromdir/" "$todir"
101$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
5794112a 102 | tee "$outfile"
8af1bc90 103filter_outfile
4f3be36e 104cat <<EOT >"$chkfile"
503f1634
WD
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
5794112a 114EOT
4f3be36e 115diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
5794112a
WD
116
117chmod 757 "$todir/foo/config1"
118touch "$todir/foo/config2"
119$RSYNC -vplrtH "$fromdir/" "$todir/" \
5794112a 120 | tee "$outfile"
8af1bc90 121filter_outfile
4f3be36e 122cat <<EOT >"$chkfile"
5794112a
WD
123foo/config2
124EOT
4f3be36e 125diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
5794112a
WD
126
127chmod 757 "$todir/foo/config1"
128touch "$todir/foo/config2"
129$RSYNC -iplrtH "$fromdir/" "$todir/" \
130 | tee "$outfile"
4f3be36e 131cat <<EOT >"$chkfile"
503f1634
WD
132.f...p... foo/config1
133>f..t.... foo/config2
5794112a 134EOT
4f3be36e 135diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
5794112a
WD
136
137mv "$todir" "$lddir"
db3ae95c 138$RSYNC -ivvplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
5794112a 139 | tee "$outfile"
8af1bc90 140filter_outfile
4f3be36e 141cat <<EOT >"$chkfile"
c202424a
WD
142cd ./
143cd bar/
144cd bar/baz/
503f1634 145cf bar/baz/rsync
c202424a 146cd foo/
503f1634
WD
147cf foo/config1
148cf foo/config2
149hf foo/extra => foo/config1
c202424a 150cL foo/sym -> ../bar/baz/rsync
5794112a 151EOT
4f3be36e 152diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
5794112a
WD
153
154rm -rf "$todir"
db3ae95c 155$RSYNC -iplrtH --copy-dest=../ld "$fromdir/" "$todir/" \
5794112a 156 | tee "$outfile"
4f3be36e 157cat <<EOT >"$chkfile"
503f1634 158hf foo/extra => foo/config1
5794112a 159EOT
4f3be36e 160diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
5794112a 161
165dd4a6
WD
162rm -rf "$todir"
163$RSYNC -vvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
164 | tee "$outfile"
165filter_outfile
166cat <<EOT >"$chkfile"
c202424a
WD
167./ is uptodate
168bar/ is uptodate
169bar/baz/ is uptodate
165dd4a6 170bar/baz/rsync is uptodate
c202424a 171foo/ is uptodate
165dd4a6
WD
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"
c202424a
WD
185cd ./
186cd bar/
187cd bar/baz/
503f1634 188hf bar/baz/rsync
c202424a 189cd foo/
503f1634
WD
190hf foo/config1
191hf foo/config2
192hf foo/extra => foo/config1
3b8ed842 193$L foo/sym -> ../bar/baz/rsync
165dd4a6
WD
194EOT
195diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
196
197rm -rf "$todir"
db3ae95c
WD
198$RSYNC -iplrtH --dry-run --link-dest=../ld "$fromdir/" "$todir/" \
199 | tee "$outfile"
200cat <<EOT >"$chkfile"
db3ae95c
WD
201EOT
202diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
203
204rm -rf "$todir"
205$RSYNC -iplrtH --link-dest=../ld "$fromdir/" "$todir/" \
165dd4a6
WD
206 | tee "$outfile"
207cat <<EOT >"$chkfile"
165dd4a6 208EOT
558d482c 209diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
165dd4a6
WD
210
211rm -rf "$todir"
212$RSYNC -vvplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
213 | tee "$outfile"
214filter_outfile
215cat <<EOT >"$chkfile"
c202424a
WD
216./ is uptodate
217bar/ is uptodate
218bar/baz/ is uptodate
165dd4a6 219bar/baz/rsync is uptodate
c202424a 220foo/ is uptodate
165dd4a6
WD
221foo/config1 is uptodate
222foo/config2 is uptodate
223"foo/extra" is a hard link
224foo/sym is uptodate
225EOT
558d482c 226diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
165dd4a6
WD
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"
c202424a
WD
235cd ./
236cd bar/
237cd bar/baz/
503f1634 238.f bar/baz/rsync
c202424a 239cd foo/
503f1634
WD
240.f foo/config1
241.f foo/config2
242.L foo/sym -> ../bar/baz/rsync
165dd4a6 243EOT
558d482c 244diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
165dd4a6
WD
245
246rm -rf "$todir"
247$RSYNC -iplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
248 | tee "$outfile"
249cat <<EOT >"$chkfile"
165dd4a6 250EOT
558d482c 251diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
165dd4a6
WD
252
253rm -rf "$todir"
254$RSYNC -vvplrtH --compare-dest="$lddir" "$fromdir/" "$todir/" \
255 | tee "$outfile"
256filter_outfile
257cat <<EOT >"$chkfile"
c202424a
WD
258./ is uptodate
259bar/ is uptodate
260bar/baz/ is uptodate
165dd4a6 261bar/baz/rsync is uptodate
c202424a 262foo/ is uptodate
165dd4a6
WD
263foo/config1 is uptodate
264foo/config2 is uptodate
265"foo/extra" is a hard link
266foo/sym is uptodate
267EOT
558d482c 268diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
165dd4a6 269
5794112a
WD
270# The script would have aborted on error, so getting here means we've won.
271exit 0