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