Check status of tests that pipe rsync's output & simplify output diffing.
[rsync.git] / testsuite / itemize.test
1 #! /bin/sh
2
3 # Copyright (C) 2005-2020 Wayne Davison
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 to2dir="$tmpdir/to2"
14
15 makepath "$fromdir/foo"
16 makepath "$fromdir/bar/baz"
17 cp_p "$srcdir/configure.ac" "$fromdir/foo/config1"
18 cp_p "$srcdir/config.sub" "$fromdir/foo/config2"
19 cp_p "$srcdir/rsync.h" "$fromdir/bar/baz/rsync"
20 chmod 600 "$fromdir"/foo/config? "$fromdir/bar/baz/rsync"
21 umask 0
22 ln -s ../bar/baz/rsync "$fromdir/foo/sym"
23 umask 022
24 ln "$fromdir/foo/config1" "$fromdir/foo/extra"
25 rm -f "$to2dir"
26
27 # Check if rsync is set to hard-link symlinks.
28 if $RSYNC --version | grep "[, ] hardlink-symlinks" >/dev/null; then
29     L=hL
30     sym_dots="$allspace"
31     L_sym_dots=".L$allspace"
32     is_uptodate='is uptodate'
33     touch "$chkfile.extra"
34 else
35     L=cL
36     sym_dots="c.t.$dots"
37     L_sym_dots="cL$sym_dots"
38     is_uptodate='-> ../bar/baz/rsync'
39     echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
40 fi
41
42 # Check if rsync can preserve time on symlinks
43 case "$RSYNC" in
44 *protocol=2*)
45     T=.T
46     ;;
47 *)
48     if $RSYNC --version | grep "[, ] symtimes" >/dev/null; then
49         T=.t
50     else
51         T=.T
52     fi
53     ;;
54 esac
55
56 checkdiff "$RSYNC -iplr '$fromdir/' '$todir/'" <<EOT
57 cd$all_plus ./
58 cd$all_plus bar/
59 cd$all_plus bar/baz/
60 >f$all_plus bar/baz/rsync
61 cd$all_plus foo/
62 >f$all_plus foo/config1
63 >f$all_plus foo/config2
64 >f$all_plus foo/extra
65 cL$all_plus foo/sym -> ../bar/baz/rsync
66 EOT
67
68 # Ensure there are no accidental directory-time problems.
69 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
70
71 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
72 chmod 601 "$fromdir/foo/config2"
73 checkdiff "$RSYNC -iplrH '$fromdir/' '$todir/'" <<EOT
74 >f..T.$dots bar/baz/rsync
75 >f..T.$dots foo/config1
76 >f.sTp$dots foo/config2
77 hf..T.$dots foo/extra => foo/config1
78 EOT
79
80 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
81 cp_p "$srcdir/config.sub" "$fromdir/foo/config2"
82 sleep 1 # For directory mod below to ensure time difference
83 rm "$todir/foo/sym"
84 umask 0
85 ln -s ../bar/baz "$todir/foo/sym"
86 umask 022
87 chmod 600 "$fromdir/foo/config2"
88 chmod 777 "$todir/bar/baz/rsync"
89
90 checkdiff "$RSYNC -iplrtc '$fromdir/' '$todir/'" <<EOT
91 .f..tp$dots bar/baz/rsync
92 .d..t.$dots foo/
93 .f..t.$dots foo/config1
94 >fcstp$dots foo/config2
95 cLc$T.$dots foo/sym -> ../bar/baz/rsync
96 EOT
97
98 cp_p "$srcdir/configure.ac" "$fromdir/foo/config2"
99 chmod 600 "$fromdir/foo/config2"
100 # Lack of -t is for unchanged hard-link stress-test!
101 checkdiff "$RSYNC -vvplrH '$fromdir/' '$todir/'" \
102         v_filt <<EOT
103 bar/baz/rsync is uptodate
104 foo/config1 is uptodate
105 foo/extra is uptodate
106 foo/sym is uptodate
107 foo/config2
108 EOT
109
110 chmod 747 "$todir/bar/baz/rsync"
111 $RSYNC -a -f '-! */' "$fromdir/" "$todir"
112 checkdiff "$RSYNC -ivvplrtH '$fromdir/' '$todir/'" \
113         v_filt <<EOT
114 .d$allspace ./
115 .d$allspace bar/
116 .d$allspace bar/baz/
117 .f...p$dots bar/baz/rsync
118 .d$allspace foo/
119 .f$allspace foo/config1
120 >f..t.$dots foo/config2
121 hf$allspace foo/extra
122 .L$allspace foo/sym -> ../bar/baz/rsync
123 EOT
124
125 chmod 757 "$todir/foo/config1"
126 touch "$todir/foo/config2"
127 checkdiff "$RSYNC -vplrtH '$fromdir/' '$todir/'" \
128         v_filt <<EOT
129 foo/config2
130 EOT
131
132 chmod 757 "$todir/foo/config1"
133 touch "$todir/foo/config2"
134 checkdiff "$RSYNC -iplrtH '$fromdir/' '$todir/'" <<EOT
135 .f...p$dots foo/config1
136 >f..t.$dots foo/config2
137 EOT
138
139 checkdiff "$RSYNC -ivvplrtH --copy-dest=../to '$fromdir/' '$to2dir/'" \
140         v_filt <<EOT
141 cd$allspace ./
142 cd$allspace bar/
143 cd$allspace bar/baz/
144 cf$allspace bar/baz/rsync
145 cd$allspace foo/
146 cf$allspace foo/config1
147 cf$allspace foo/config2
148 hf$allspace foo/extra => foo/config1
149 cL$sym_dots foo/sym -> ../bar/baz/rsync
150 EOT
151
152 rm -rf "$to2dir"
153 cat - "$chkfile.extra" <<EOT >"$chkfile"
154 hf$allspace foo/extra => foo/config1
155 EOT
156 checkdiff2 "$RSYNC -iplrtH --copy-dest=../to '$fromdir/' '$to2dir/'"
157
158 rm -rf "$to2dir"
159 checkdiff "$RSYNC -vvplrtH --copy-dest='$todir' '$fromdir/' '$to2dir/'" \
160         v_filt <<EOT
161 ./ is uptodate
162 bar/ is uptodate
163 bar/baz/ is uptodate
164 bar/baz/rsync is uptodate
165 foo/ is uptodate
166 foo/config1 is uptodate
167 foo/config2 is uptodate
168 foo/sym $is_uptodate
169 foo/extra => foo/config1
170 EOT
171
172 rm -rf "$to2dir"
173 checkdiff "$RSYNC -ivvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
174         v_filt <<EOT
175 cd$allspace ./
176 cd$allspace bar/
177 cd$allspace bar/baz/
178 hf$allspace bar/baz/rsync
179 cd$allspace foo/
180 hf$allspace foo/config1
181 hf$allspace foo/config2
182 hf$allspace foo/extra => foo/config1
183 $L$sym_dots foo/sym -> ../bar/baz/rsync
184 EOT
185
186 rm -rf "$to2dir"
187 checkdiff "$RSYNC -iplrtH --dry-run --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
188
189 rm -rf "$to2dir"
190 checkdiff "$RSYNC -iplrtH --link-dest=../to '$fromdir/' '$to2dir/'" <"$chkfile.extra"
191
192 rm -rf "$to2dir"
193 checkdiff "$RSYNC -vvplrtH --link-dest='$todir' '$fromdir/' '$to2dir/'" \
194         v_filt <<EOT
195 ./ is uptodate
196 bar/ is uptodate
197 bar/baz/ is uptodate
198 bar/baz/rsync is uptodate
199 foo/ is uptodate
200 foo/config1 is uptodate
201 foo/config2 is uptodate
202 foo/extra is uptodate
203 foo/sym $is_uptodate
204 EOT
205
206 rm -rf "$to2dir"
207 checkdiff "$RSYNC -ivvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
208         v_filt <<EOT
209 cd$allspace ./
210 cd$allspace bar/
211 cd$allspace bar/baz/
212 .f$allspace bar/baz/rsync
213 cd$allspace foo/
214 .f$allspace foo/config1
215 .f$allspace foo/config2
216 .f$allspace foo/extra
217 $L_sym_dots foo/sym -> ../bar/baz/rsync
218 EOT
219
220 rm -rf "$to2dir"
221 checkdiff "$RSYNC -iplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" <"$chkfile.extra"
222
223 rm -rf "$to2dir"
224 checkdiff "$RSYNC -vvplrtH --compare-dest='$todir' '$fromdir/' '$to2dir/'" \
225         v_filt <<EOT
226 ./ is uptodate
227 bar/ is uptodate
228 bar/baz/ is uptodate
229 bar/baz/rsync is uptodate
230 foo/ is uptodate
231 foo/config1 is uptodate
232 foo/config2 is uptodate
233 foo/extra is uptodate
234 foo/sym $is_uptodate
235 EOT
236
237 # The script would have aborted on error, so getting here means we've won.
238 exit 0