]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/regexwhere-test
Fix status alignment output reported by Wanderlei Huttel
[bacula/bacula] / regress / tests / regexwhere-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 #  Test file relocation feature
9 #
10
11 TestName="regexwhere-test"
12 JobName=backup
13
14 . scripts/functions
15
16 scripts/cleanup
17 scripts/copy-test-confs
18
19 /bin/cp -f scripts/bacula-dir.conf.regexwhere bin/bacula-dir.conf
20
21 #
22 # Remove the !restored from the messages resource because
23 #  this test needs the restored listing to verify the
24 #  restore results
25 #
26 outf="${cwd}/tmp/sed_tmp"
27 echo "s%, \!restored%%g" >${outf}
28 cp ${cwd}/bin/bacula-fd.conf ${cwd}/tmp/1
29 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-fd.conf
30
31 echo "${cwd}/build/po" >tmp/file-list
32
33 start_test
34
35 cat <<END_OF_DATA >tmp/bconcmds
36 @$out tmp/RUN_backup
37 messages
38 label volume=TestVolume001
39 run job=backup yes
40 wait
41 messages
42 @##################################
43 @$out tmp/RUN_JobA
44 restore
45 5
46 cd ${cwd}/build/po
47 m *.po
48 done
49 1
50 yes
51 wait
52 messages
53 @##################################
54 @$out tmp/RUN_JobB
55 restore
56 5
57 cd ${cwd}/build/po
58 m *.po
59 done
60 2
61 yes
62 wait
63 messages
64 @##################################
65 @$out tmp/RUN_JobC
66 restore
67 5
68 cd ${cwd}/build/po
69 m *.po
70 done
71 3
72 yes
73 wait
74 messages
75 @##################################
76 @$out tmp/RUN_JobD
77 restore
78 5
79 cd ${cwd}/build/po
80 m *.po
81 done
82 4
83 yes
84 wait
85 messages
86 @##################################
87 @$out tmp/RUN_JobE
88 restore
89 5
90 cd ${cwd}/build/po
91 m *.po
92 done
93 5
94 yes
95 wait
96 messages
97 @##################################
98 @$out tmp/RUN_JobF
99 restore
100 5
101 cd ${cwd}/build/po
102 m *.po
103 done
104 6
105 yes
106 wait
107 messages
108 @##################################
109 @$out tmp/RUN_JobG
110 restore strip_prefix="${cwd}" add_prefix="${tmp}/bacula-restore.$$"
111 5
112 cd ${cwd}/build/po
113 m *.po
114 done
115 7
116 yes
117 wait
118 messages
119 @##################################
120 @$out tmp/RUN_JobH
121 restore add_suffix=.old
122 5
123 cd ${cwd}/build/po
124 m *.po
125 done
126 7
127 yes
128 wait
129 messages
130 @##################################
131 @$out tmp/RUN_JobI
132 restore regexwhere="!Po!old!i,!old!po!,!\$!.old!"
133 5
134 cd ${cwd}/build/po
135 m *.po
136 done
137 7
138 yes
139 wait
140 messages
141 @##################################
142 @$out tmp/RUN_JobJ
143 restore
144 5
145 cd ${cwd}/build/po
146 m *.po
147 done
148 7
149 mod
150 @## File Relocation -> add suffix -> test -> accept
151 10
152 3
153 .old
154 5
155 /etc/passwd
156 .
157 6
158 @## Where 
159 m
160 9
161 tmp/bacula-restore-it
162 m
163 @## use add suffix
164 10
165 3
166 .old
167 6
168 yes
169 wait
170 messages
171 @sleep 1
172 quit
173 END_OF_DATA
174
175 run_bacula
176
177 stop_bacula
178
179
180 dstat=0
181 bstat=0
182 rstat=0
183 export dstat
184 export bstat
185 export rstat
186
187 J=JobA
188 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
189 grep "${cwd}/build/po/fr.old.po" tmp/RUN_$J > /dev/null
190
191 if [ $? = 0 ] 
192 then
193     [ "$debug" = 1 ] && echo $J ok
194 else
195    echo "$J in error"
196    rstat=1
197 fi
198
199 J=JobB
200 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
201 grep "tmp/bacula-restore${cwd}/po/fr.po.old" tmp/RUN_$J > /dev/null
202 # $cwd begins with /
203 if [ $? = 0 ]
204 then
205     [ "$debug" = 1 ] && echo $J ok
206 else
207    echo "$J in error"
208    rstat=1
209 fi
210
211 J=JobC
212 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
213 grep "tmp/bacula-restore${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
214 if [ $? = 0 ]
215 then
216     [ "$debug" = 1 ] && echo $J ok
217 else
218    echo "$J in error"
219    rstat=1
220 fi
221
222 J=JobD
223 grep "Restore Error"  tmp/RUN_$J > /dev/null
224 if [ $? = 0 ]
225 then
226     [ "$debug" = 1 ] && echo $J ok
227 else
228    echo "$J in error"
229    rstat=1
230 fi
231
232 J=JobE
233 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
234 grep "${cwd}/tmp/fr.po"  tmp/RUN_$J > /dev/null
235 if [ $? = 0 ]
236 then
237     [ "$debug" = 1 ] && echo $J ok
238 else
239    echo "$J in error"
240    rstat=1
241 fi
242
243 J=JobF
244 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
245 grep "${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
246 if [ $? = 0 ]
247 then
248     [ "$debug" = 1 ] && echo $J ok
249 else
250    echo "$J in error"
251    rstat=1
252 fi
253
254 J=JobG
255 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
256 grep "tmp/bacula-restore.$$/build/po/fr.po" tmp/RUN_$J > /dev/null
257 if [ $? = 0 ]
258 then
259     [ "$debug" = 1 ] && echo $J ok
260 else
261    echo "$J in error"
262    rstat=1
263 fi
264 rm -rf ${tmp}/bacula-restore.$$
265
266 J=JobH
267 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
268 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
269 if [ $? = 0 ]
270 then
271     [ "$debug" = 1 ] && echo $J ok
272 else
273    echo "$J in error"
274    rstat=1
275 fi
276
277 J=JobI
278 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
279 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
280 if [ $? = 0 ]
281 then
282     [ "$debug" = 1 ] && echo $J ok
283 else
284    echo "$J in error"
285    rstat=1
286 fi
287
288
289 J=JobJ
290 grep "Restore OK"      tmp/RUN_$J > /dev/null && \
291 grep "/etc/passwd.old" tmp/RUN_$J > /dev/null && \
292 grep "Where: *tmp/bacula-restore-it" tmp/RUN_$J > /dev/null && \
293 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
294 if [ $? = 0 ]
295 then
296     [ "$debug" = 1 ] && echo $J ok
297 else
298    echo "$J in error"
299    rstat=1
300 fi
301
302 # test with bregtest
303
304 find ${cwd}/build > tmp/list
305 # thanks to BSD like system for that...
306 sed -e 's/[Rr][Ee][Aa][Dd][Mm][Ee]/readme/' -e 's/\([ch]\)$/.old.\1/' tmp/list > tmp/list.sed
307 ./build/src/tools/bregtest -s -f tmp/list -e '/readme/readme/i,/([ch])$/.old.$1/' > tmp/list.bsed
308
309 diff tmp/list.bsed tmp/list.sed >/dev/null 2>&1
310 if [ $? = 0 ]
311 then
312     [ "$debug" = 1 ] && echo bregtest ok
313 else
314    echo "bregtest test in error"
315    rstat=1
316
317 fi
318
319 end_test