# # A set of useful functions to be sourced in each test # start_test() { echo " " echo " " echo " === Starting $JobName at `date +%R:%S` ===" echo " === Starting $JobName at `date +%R:%S` ===" >>working/log echo " " } set_debug() { debug=$1 if test "$debug" -eq 1 ; then out="tee" else out="output" fi } run_bacula() { if test "$debug" -eq 1 ; then bin/bacula start cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf else bin/bacula start 2>&1 >/dev/null cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null fi } run_bconsole() { if test "$debug" -eq 1 ; then cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf else cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null fi } stop_bacula() { bin/bacula stop 2>&1 >/dev/null } check_for_zombie_jobs() { scripts/check_for_zombie_jobs $1 } change_jobname() { rm -f bin/1 mv bin/bacula-dir.conf bin/1 echo "s%NightlySave%$1%g" >/tmp/1 sed -f /tmp/1 bin/1 >bin/bacula-dir.conf } check_two_logs() { grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null bstat=$? grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null rstat=$? } check_restore_diff() { diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null dstat=$? } check_restore_tmp_build_diff() { diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null dstat=$? } end_test() { if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then echo " " echo " " echo " !!!!! $TestName Bacula source failed!!! !!!!! " echo " !!!!! $TestName failed!!! !!!!! " >>test.out if [ $bstat != 0 -o $rstat != 0 ] ; then echo " !!!!! Bad Job termination status !!!!! " echo " !!!!! Bad Job termination status !!!!! " >>test.out else echo " !!!!! Restored files differ !!!!! " echo " !!!!! Restored files differ !!!!! " >>test.out fi echo " " else echo " ===== $TestName Bacula source OK `date +%R:%S` ===== " echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out scripts/cleanup fi }