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