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