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