X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=regress%2Fscripts%2Ffunctions;h=c544183f17d997e87b7bde6645b54771a93750af;hb=46ca5543e540fe87ace0d6b2b104a6147b4d1a7e;hp=12d05f4cccd944c69fab191e098173f993357f70;hpb=846585b2a47f5ef0e1360476120960dcea4cb6e9;p=bacula%2Fbacula diff --git a/regress/scripts/functions b/regress/scripts/functions index 12d05f4ccc..c544183f17 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -4,11 +4,64 @@ start_test() { + # Turn off email + outf="tmp/sed_tmp" + echo "s% mail =%# mail = %g" >${outf} + echo "s% operator =%# operator =%g" >>${outf} + cp bin/bacula-dir.conf tmp/1 + sed -f ${outf} tmp/1 >bin/bacula-dir.conf echo " " echo " " echo " === Starting $TestName at `date +%R:%S` ===" echo " === Starting $TestName at `date +%R:%S` ===" >>working/log echo " " + export zstat +} + +require_root() +{ +MUID=`/usr/bin/id | awk -F= '{print $2}' | awk -F\( '{print $1}'` +if [ $MUID != 0 ] ; then + echo " " + echo "You must be root to run this test." + echo " ===== !!!! $TestName not run at `date +%R:%S` ===" + echo " ===== !!!! $TestName not run at `date +%R:%S` !!!! ===== " >>test.out + echo " " + exit 1 +fi +} + +require_tape_drive() +{ +if test x${TAPE_DRIVE} = x/dev/null ; then + echo "$TestName test needs a tape drive, but has none." + exit 1 +fi +} + +require_second_drive() +{ +if test x${TAPE_DRIVE1} = x/dev/null ; then + echo "$JobName needs second drive, but has none." + exit 1 +fi +} + +require_autochanger() +{ +if test x${AUTOCHANGER} = x/dev/null ; then + echo "$TestName needs an autochanger, but has none." + exit 1 +fi +} + + +skip_if_no_autochanger() +{ +if test x${AUTOCHANGER} = x/dev/null ; then + echo "$TestName test skipped. No autochanger." + exit +fi } set_debug() @@ -21,10 +74,21 @@ set_debug() fi } +print_debug() +{ + if test "$debug" -eq 1 ; then + echo $* + fi +} + run_bacula() { + debug_wait + zstat=0 if test "$debug" -eq 1 ; then - bin/bacula start + bin/bacula-ctl-sd start + bin/bacula-ctl-fd start + bin/bacula-ctl-dir start cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf else bin/bacula start 2>&1 >/dev/null @@ -50,6 +114,30 @@ run_btape() fi } +run_bscan() +{ + if test "$debug" -eq 1 ; then + bin/bscan $* | tee tmp/log.out + else + bin/bscan $* 2>&1 >/dev/null + fi +} + +bscan_libdbi() +{ + B=`echo $LIBDBI | sed 's/;//' | sed 's/;//g'` + B_D=`echo $B | awk '{print $3}'` + B_t=`echo $B | awk '{print $6}'` + B_p=`echo $B | awk '{print $9}'` + + BSCANLIBDBI="${LIBDBI:+1}" + + if test "$BSCANLIBDBI" = "1" ; then + BSCANLIBDBI="-D $B_D -h $B_t -t $B_p" + else + BSCANLIBDBI=" " + fi +} stop_bacula() { @@ -58,12 +146,12 @@ stop_bacula() check_for_zombie_jobs() { - scripts/check_for_zombie_jobs $1 + scripts/check_for_zombie_jobs $* } change_jobname() { - if test $# == 1; then + if test $# -eq 1; then oldname=NightlySave newname=$1 else @@ -72,8 +160,8 @@ change_jobname() fi rm -f bin/1 mv bin/bacula-dir.conf bin/1 - echo "s%${oldname}%${newname}%g" >/tmp/1 - sed -f /tmp/1 bin/1 >bin/bacula-dir.conf + echo "s%${oldname}%${newname}%g" >tmp/1 + sed -f tmp/1 bin/1 >bin/bacula-dir.conf # echo "Job ${oldname} changed to ${newname}" } @@ -81,8 +169,20 @@ check_two_logs() { grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null bstat=$? + grep "^ Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null + if test $? -eq 0; then + bstat=2 + fi grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null rstat=$? + grep "^ Termination: *Restore OK -- warning file count mismatch" tmp/log2.out 2>&1 >/dev/null + if test $? -eq 0; then + rstat=2 + fi + grep "^ Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null + if test $? -eq 0; then + rstat=3 + fi } check_restore_diff() @@ -99,23 +199,36 @@ check_restore_tmp_build_diff() end_test() { + if [ $zstat != 0 ] ; then + echo " " + echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " + echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out + echo " Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out + echo " " + exit 1 + fi if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then echo " " echo " " - echo " !!!!! $TestName Bacula source failed!!! !!!!! " - echo " !!!!! $TestName failed!!! !!!!! " >>test.out + echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " + echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out if [ $bstat != 0 -o $rstat != 0 ] ; then - echo " !!!!! Bad Job termination status !!!!! " - echo " !!!!! Bad Job termination status !!!!! " >>test.out + echo " !!!!! Bad termination status !!!!! " + echo " !!!!! Bad termination status !!!!! " >>test.out else echo " !!!!! Restored files differ !!!!! " echo " !!!!! Restored files differ !!!!! " >>test.out fi + echo " Status: backup=$bstat restore=$rstat diff=$dstat" + echo " Status: backup=$bstat restore=$rstat diff=$dstat" >>test.out echo " " + exit 1 else - echo " ===== $TestName Bacula source OK `date +%R:%S` ===== " + echo " ===== $TestName OK `date +%R:%S` ===== " echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out - scripts/cleanup + if test "$debug" -eq 0 ; then + scripts/cleanup + fi fi } @@ -131,6 +244,31 @@ copy_test_confs() scripts/cleanup } +debug_wait() +{ + if test "x${REGRESS_WAIT}" = "x1"; then + echo "Start Bacula under debugger and enter anything when ready ..." + read a + fi +} + +init_drive() +{ + if test a$USE_FAKETAPE = a; then + mt -f $1 rewind + mt -f $1 weof + else + cp /dev/null $1 + fi +} # Save current directory cwd=`pwd` +if test "x${REGRESS_DEBUG}" = "x1"; then + set_debug 1 +else + set_debug 0 +fi + +# Source the configuration variables +. ${cwd}/config