Test that our outputting of itemized messages (as well as
[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
15itemregex='^[.<>ch][dfDL][c .+][s .+][tT .+][p .+][o .+][g .+][a .+] '
16
17lddir="$tmpdir/ld"
18
19outfile="$scratchdir/rsync.out"
20
21makepath "$fromdir/foo"
22makepath "$fromdir/bar/baz"
23cp -p "$srcdir/config.h" "$fromdir/foo/config1"
24cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
25cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
26ln -s ../bar/baz/rsync "$fromdir/foo/sym"
27ln "$fromdir/foo/config1" "$fromdir/foo/extra"
28
29$RSYNC -iplr "$fromdir/" "$todir/" \
30 | tee "$outfile"
31cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 1 failed"
32cd+++++++ bar/
33cd+++++++ bar/baz/
34>f+++++++ bar/baz/rsync
35cd+++++++ foo/
36>f+++++++ foo/config1
37>f+++++++ foo/config2
38>f+++++++ foo/extra
39cL+++++++ foo/sym -> ../bar/baz/rsync
40EOT
41
42# Ensure there are no accidental directory-time problems.
43$RSYNC -a -f '-! */' "$fromdir/" "$todir"
44
45cp -p "$srcdir/config.h" "$fromdir/foo/config2"
46$RSYNC -iplrH "$fromdir/" "$todir/" \
47 | tee "$outfile"
48cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 2 failed"
49>f..T.... bar/baz/rsync
50>f..T.... foo/config1
51>f.sT.... foo/config2
52hf..T.... foo/extra => foo/config1
53EOT
54
55$RSYNC -a -f '-! */' "$fromdir/" "$todir"
56sleep 1 # For directory mod below to ensure time difference
57rm "$todir/foo/sym"
58ln -s ../bar/baz "$todir/foo/sym"
59cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
60chmod 777 "$todir/bar/baz/rsync"
61
62$RSYNC -iplrtc "$fromdir/" "$todir/" \
63 | tee "$outfile"
64cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 3 failed"
65.f..tp... bar/baz/rsync
66.d..t.... foo/
67.f..t.... foo/config1
68>fcst.... foo/config2
69cL..T.... foo/sym -> ../bar/baz/rsync
70EOT
71
72cp -p "$srcdir/config.h" "$fromdir/foo/config2"
73# Lack of -t is for unchanged hard-link stress-test!
74$RSYNC -vvplrH "$fromdir/" "$todir/" \
75 | sed -e '0,/done$/d' -e '/--whole-file/d' -e '/total:/d' -e '/^$/,$d' \
76 | tee "$outfile"
77cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 4 failed"
78bar/baz/rsync is uptodate
79foo/config1 is uptodate
80foo/config2
81"foo/extra" is a hard link
82foo/sym is uptodate
83EOT
84
85chmod 747 "$todir/bar/baz/rsync"
86$RSYNC -a -f '-! */' "$fromdir/" "$todir"
87$RSYNC -ivvplrtH "$fromdir/" "$todir/" \
88 | grep "$itemregex" \
89 | tee "$outfile"
90cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 5 failed"
91.d ./
92.d bar/
93.d bar/baz/
94.f...p... bar/baz/rsync
95.d foo/
96.f foo/config1
97>f..t.... foo/config2
98hf foo/extra
99.L foo/sym -> ../bar/baz/rsync
100EOT
101
102chmod 757 "$todir/foo/config1"
103touch "$todir/foo/config2"
104$RSYNC -vplrtH "$fromdir/" "$todir/" \
105 | sed -e '0,/done$/d' -e '/^$/,$d' \
106 | tee "$outfile"
107cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 6 failed"
108foo/config2
109EOT
110
111chmod 757 "$todir/foo/config1"
112touch "$todir/foo/config2"
113$RSYNC -iplrtH "$fromdir/" "$todir/" \
114 | tee "$outfile"
115cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 7 failed"
116.f...p... foo/config1
117>f..t.... foo/config2
118EOT
119
120mv "$todir" "$lddir"
121$RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
122 | grep "$itemregex" \
123 | tee "$outfile"
124cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 8 failed"
125.d..t.... ./
126cd+++++++ bar/
127cd+++++++ bar/baz/
128cf....... bar/baz/rsync
129cd+++++++ foo/
130cf....... foo/config1
131cf....... foo/config2
132hf+++++++ foo/extra => foo/config1
133cL+++++++ foo/sym -> ../bar/baz/rsync
134EOT
135
136rm -rf "$todir"
137$RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
138 | tee "$outfile"
139cat <<EOT | diff $diffopt - "$outfile" || test_fail "test 9 failed"
140.d..t.... ./
141cd+++++++ bar/
142cd+++++++ bar/baz/
143cd+++++++ foo/
144hf+++++++ foo/extra => foo/config1
145cL+++++++ foo/sym -> ../bar/baz/rsync
146EOT
147
148# The script would have aborted on error, so getting here means we've won.
149exit 0