Simplified the regular expressions for sed due to problems on some
[rsync.git] / testsuite / itemize.test
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
13 set -x
14
15 lddir="$tmpdir/ld"
16
17 chkfile="$scratchdir/rsync.chk"
18 outfile="$scratchdir/rsync.out"
19
20 filter_outfile() {
21     sed -e '/^building file list /d' \
22         -e '/^created directory /d' \
23         -e '/^done$/d' \
24         -e '/ --whole-file$/d' \
25         -e '/^total: /d' \
26         -e '/^$/,$d' \
27         <"$outfile" >"$outfile.new"
28     mv "$outfile.new" "$outfile"
29 }
30
31 makepath "$fromdir/foo"
32 makepath "$fromdir/bar/baz"
33 cp -p "$srcdir/config.h" "$fromdir/foo/config1"
34 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
35 cp -p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
36 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
37 umask 0
38 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
39 umask 022
40 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
41
42 $RSYNC -iplr "$fromdir/" "$todir/" \
43     | tee "$outfile"
44 cat <<EOT >"$chkfile"
45 cd+++++++ bar/
46 cd+++++++ bar/baz/
47 >f+++++++ bar/baz/rsync
48 cd+++++++ foo/
49 >f+++++++ foo/config1
50 >f+++++++ foo/config2
51 >f+++++++ foo/extra
52 cL+++++++ foo/sym -> ../bar/baz/rsync
53 EOT
54 diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
55
56 # Ensure there are no accidental directory-time problems.
57 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
58
59 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
60 chmod 601 "$fromdir/foo/config2"
61 $RSYNC -iplrH "$fromdir/" "$todir/" \
62     | tee "$outfile"
63 cat <<EOT >"$chkfile"
64 >f..T.... bar/baz/rsync
65 >f..T.... foo/config1
66 >f.sTp... foo/config2
67 hf..T.... foo/extra => foo/config1
68 EOT
69 diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
70
71 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
72 sleep 1 # For directory mod below to ensure time difference
73 rm "$todir/foo/sym"
74 umask 0
75 ln -s ../bar/baz "$todir/foo/sym"
76 umask 022
77 cp -p "$srcdir/config.h.in" "$fromdir/foo/config2"
78 chmod 600 "$fromdir/foo/config2"
79 chmod 777 "$todir/bar/baz/rsync"
80
81 $RSYNC -iplrtc "$fromdir/" "$todir/" \
82     | tee "$outfile"
83 cat <<EOT >"$chkfile"
84 .f..tp... bar/baz/rsync
85 .d..t.... foo/
86 .f..t.... foo/config1
87 >fcstp... foo/config2
88 cL..T.... foo/sym -> ../bar/baz/rsync
89 EOT
90 diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
91
92 cp -p "$srcdir/config.h" "$fromdir/foo/config2"
93 chmod 600 "$fromdir/foo/config2"
94 # Lack of -t is for unchanged hard-link stress-test!
95 $RSYNC -vvplrH "$fromdir/" "$todir/" \
96     | tee "$outfile"
97 cat <<EOT >"$chkfile"
98 bar/baz/rsync is uptodate
99 foo/config1 is uptodate
100 foo/config2
101 "foo/extra" is a hard link
102 foo/sym is uptodate
103 EOT
104 filter_outfile
105 diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
106
107 chmod 747 "$todir/bar/baz/rsync"
108 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
109 $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
110     | tee "$outfile"
111 cat <<EOT >"$chkfile"
112 .d        ./
113 .d        bar/
114 .d        bar/baz/
115 .f...p... bar/baz/rsync
116 .d        foo/
117 .f        foo/config1
118 >f..t.... foo/config2
119 hf        foo/extra
120 .L        foo/sym -> ../bar/baz/rsync
121 EOT
122 filter_outfile
123 diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
124
125 chmod 757 "$todir/foo/config1"
126 touch "$todir/foo/config2"
127 $RSYNC -vplrtH "$fromdir/" "$todir/" \
128     | tee "$outfile"
129 cat <<EOT >"$chkfile"
130 foo/config2
131 EOT
132 filter_outfile
133 diff $diffopt "$chkfile" "$outfile" || test_fail "test 6 failed"
134
135 chmod 757 "$todir/foo/config1"
136 touch "$todir/foo/config2"
137 $RSYNC -iplrtH "$fromdir/" "$todir/" \
138     | tee "$outfile"
139 cat <<EOT >"$chkfile"
140 .f...p... foo/config1
141 >f..t.... foo/config2
142 EOT
143 diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
144
145 mv "$todir" "$lddir"
146 $RSYNC -ivvplrtH --copy-dest="$lddir" "$fromdir/" "$todir/" \
147     | tee "$outfile"
148 cat <<EOT >"$chkfile"
149 .d..t.... ./
150 cd+++++++ bar/
151 cd+++++++ bar/baz/
152 cf....... bar/baz/rsync
153 cd+++++++ foo/
154 cf....... foo/config1
155 cf....... foo/config2
156 hf+++++++ foo/extra => foo/config1
157 cL+++++++ foo/sym -> ../bar/baz/rsync
158 EOT
159 filter_outfile
160 diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
161
162 rm -rf "$todir"
163 $RSYNC -iplrtH --link-dest="$lddir" "$fromdir/" "$todir/" \
164     | tee "$outfile"
165 cat <<EOT >"$chkfile"
166 .d..t.... ./
167 cd+++++++ bar/
168 cd+++++++ bar/baz/
169 cd+++++++ foo/
170 hf+++++++ foo/extra => foo/config1
171 cL+++++++ foo/sym -> ../bar/baz/rsync
172 EOT
173 diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
174
175 # The script would have aborted on error, so getting here means we've won.
176 exit 0