3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Test file relocation feature
11 TestName="regexwhere-test"
17 scripts/copy-test-confs
19 /bin/cp -f scripts/bacula-dir.conf.regexwhere bin/bacula-dir.conf
22 # Remove the !restored from the messages resource because
23 # this test needs the restored listing to verify the
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
31 echo "${cwd}/build/po" >tmp/file-list
35 cat <<END_OF_DATA >tmp/bconcmds
38 label volume=TestVolume001
42 @##################################
53 @##################################
64 @##################################
75 @##################################
86 @##################################
97 @##################################
108 @##################################
110 restore strip_prefix="${cwd}" add_prefix="${tmp}/bacula-restore.$$"
119 @##################################
121 restore add_suffix=.old
130 @##################################
132 restore regexwhere="!Po!old!i,!old!po!,!\$!.old!"
141 @##################################
150 @## File Relocation -> add suffix -> test -> accept
161 tmp/bacula-restore-it
188 grep "Restore OK" tmp/RUN_$J > /dev/null && \
189 grep "${cwd}/build/po/fr.old.po" tmp/RUN_$J > /dev/null
193 [ "$debug" = 1 ] && echo $J ok
200 grep "Restore OK" tmp/RUN_$J > /dev/null && \
201 grep "tmp/bacula-restore${cwd}/po/fr.po.old" tmp/RUN_$J > /dev/null
205 [ "$debug" = 1 ] && echo $J ok
212 grep "Restore OK" tmp/RUN_$J > /dev/null && \
213 grep "tmp/bacula-restore${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
216 [ "$debug" = 1 ] && echo $J ok
223 grep "Restore Error" tmp/RUN_$J > /dev/null
226 [ "$debug" = 1 ] && echo $J ok
233 grep "Restore OK" tmp/RUN_$J > /dev/null && \
234 grep "${cwd}/tmp/fr.po" tmp/RUN_$J > /dev/null
237 [ "$debug" = 1 ] && echo $J ok
244 grep "Restore OK" tmp/RUN_$J > /dev/null && \
245 grep "${cwd}/build/po/fr.po" tmp/RUN_$J > /dev/null
248 [ "$debug" = 1 ] && echo $J ok
255 grep "Restore OK" tmp/RUN_$J > /dev/null && \
256 grep "tmp/bacula-restore.$$/build/po/fr.po" tmp/RUN_$J > /dev/null
259 [ "$debug" = 1 ] && echo $J ok
264 rm -rf ${tmp}/bacula-restore.$$
267 grep "Restore OK" tmp/RUN_$J > /dev/null && \
268 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
271 [ "$debug" = 1 ] && echo $J ok
278 grep "Restore OK" tmp/RUN_$J > /dev/null && \
279 grep "${cwd}/build/po/fr.po.old" tmp/RUN_$J > /dev/null
282 [ "$debug" = 1 ] && echo $J ok
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
296 [ "$debug" = 1 ] && echo $J ok
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
309 diff tmp/list.bsed tmp/list.sed >/dev/null 2>&1
312 [ "$debug" = 1 ] && echo bregtest ok
314 echo "bregtest test in error"