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