]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/regexwhere-test
ebl more fixes
[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 pool=Default
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 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
184 grep "${cwd}/build/po/fr.old.po" tmp/RUN_$J > /dev/null
185
186 if [ $? = 0 ] 
187 then
188     [ "$debug" = 1 ] && echo $J ok
189 else
190    echo "$J in error"
191    rstat=1
192 fi
193
194 J=JobB
195 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
196 grep "tmp/bacula-restore${cwd}/po/fr.po.old" tmp/RUN_$J > /dev/null
197 # $cwd begins with /
198 if [ $? = 0 ]
199 then
200     [ "$debug" = 1 ] && echo $J ok
201 else
202    echo "$J in error"
203    rstat=1
204 fi
205
206 J=JobC
207 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
208 grep "tmp/bacula-restore${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
209 if [ $? = 0 ]
210 then
211     [ "$debug" = 1 ] && echo $J ok
212 else
213    echo "$J in error"
214    rstat=1
215 fi
216
217 J=JobD
218 grep "Restore Error"  tmp/RUN_$J > /dev/null
219 if [ $? = 0 ]
220 then
221     [ "$debug" = 1 ] && echo $J ok
222 else
223    echo "$J in error"
224    rstat=1
225 fi
226
227 J=JobE
228 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
229 grep "${cwd}/tmp/fr.po"  tmp/RUN_$J > /dev/null
230 if [ $? = 0 ]
231 then
232     [ "$debug" = 1 ] && echo $J ok
233 else
234    echo "$J in error"
235    rstat=1
236 fi
237
238 J=JobF
239 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
240 grep "${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
241 if [ $? = 0 ]
242 then
243     [ "$debug" = 1 ] && echo $J ok
244 else
245    echo "$J in error"
246    rstat=1
247 fi
248
249 J=JobG
250 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
251 grep "tmp/bacula-restore.$$/build/po/fr.po" tmp/RUN_$J > /dev/null
252 if [ $? = 0 ]
253 then
254     [ "$debug" = 1 ] && echo $J ok
255 else
256    echo "$J in error"
257    rstat=1
258 fi
259 rm -rf /tmp/bacula-restore.$$
260
261 J=JobH
262 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
263 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
264 if [ $? = 0 ]
265 then
266     [ "$debug" = 1 ] && echo $J ok
267 else
268    echo "$J in error"
269    rstat=1
270 fi
271
272 J=JobI
273 grep "Restore OK"  tmp/RUN_$J > /dev/null && \
274 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
275 if [ $? = 0 ]
276 then
277     [ "$debug" = 1 ] && echo $J ok
278 else
279    echo "$J in error"
280    rstat=1
281 fi
282
283
284 J=JobJ
285 grep "Restore OK"      tmp/RUN_$J > /dev/null && \
286 grep "/etc/passwd.old" tmp/RUN_$J > /dev/null && \
287 grep "Where: *tmp/bacula-restore-it" tmp/RUN_$J > /dev/null && \
288 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
289 if [ $? = 0 ]
290 then
291     [ "$debug" = 1 ] && echo $J ok
292 else
293    echo "$J in error"
294    rstat=1
295 fi
296
297 # test with bregtest
298
299 find ${cwd}/build > tmp/list
300 # thanks to BSD like system for that...
301 sed -e 's/[Rr][Ee][Aa][Dd][Mm][Ee]/readme/' -e 's/\([ch]\)$/.old.\1/' tmp/list > tmp/list.sed
302 ./build/src/tools/bregtest -s -f tmp/list -e '/readme/readme/i,/([ch])$/.old.$1/' > tmp/list.bsed
303
304 diff tmp/list.bsed tmp/list.sed >/dev/null 2>&1
305 if [ $? = 0 ]
306 then
307     [ "$debug" = 1 ] && echo bregtest ok
308 else
309    echo "bregtest test in error"
310    rstat=1
311
312 fi
313
314 end_test