]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/scripts/functions
ebl update for next-vol test
[bacula/bacula] / regress / scripts / functions
index e46599fe770d06d78c88b1f25d6564c581de981a..96095a3981a661e17e56215a9fb5c465141dbecb 100644 (file)
@@ -2,13 +2,21 @@
 # A set of useful functions to be sourced in each test
 #
 
+
 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()
@@ -24,6 +32,45 @@ if [ $MUID != 0 ] ; then
 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
+}
+
+require_vtape() 
+{
+if test x${USE_VTAPE} = x ; then
+   echo "$TestName test needs the vtape driver."
+   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()
 {
@@ -35,9 +82,17 @@ 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-ctl-sd start
      bin/bacula-ctl-fd start
@@ -76,6 +131,21 @@ run_bscan()
    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()
 {
@@ -107,7 +177,7 @@ 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
+   grep "^  Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null
    if test $? -eq 0; then
       bstat=2
    fi
@@ -117,7 +187,7 @@ check_two_logs()
    if test $? -eq 0; then
       rstat=2
    fi
-   grep "^  Termination: *Verify Differences" tmp/log2.out 2>&1 >/dev/null
+   grep "^  Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null
    if test $? -eq 0; then
       rstat=3
    fi
@@ -137,6 +207,14 @@ 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 " "
@@ -145,15 +223,14 @@ end_test()
       if [ $bstat != 0 -o $rstat != 0 ] ; then
          echo "  !!!!! Bad termination status       !!!!! "
          echo "  !!!!! Bad termination status       !!!!! " >>test.out
-         echo "   Status: backup=$bstat restore=$rstat diff=$dstat"
-         echo "   Status: backup=$bstat restore=$rstat diff=$dstat" >>test.out
       else
          echo "  !!!!! Restored files differ          !!!!! "
          echo "  !!!!! Restored files differ          !!!!! " >>test.out
-         echo "   Status: backup=$bstat restore=$rstat diff=$dstat"
-         echo "   Status: backup=$bstat restore=$rstat diff=$dstat" >>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 OK `date +%R:%S` ===== "
       echo "  ===== $TestName OK `date +%R:%S` ===== " >>test.out
@@ -183,6 +260,28 @@ debug_wait()
   fi
 }
 
+init_slot()
+{
+   DRIVE=$1
+   SLOT=$2
+   if test -n "$DRIVE" -a -n "$SLOT"; then
+      if test ! -c $DRIVE -a ! -b $DRIVE -a x$USE_VTAPE != x ; then
+         dir=`dirname $DRIVE`
+         touch $dir/slot$SLOT
+      fi
+   fi
+}
+
+init_drive()
+{
+  if test a$USE_VTAPE = 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
@@ -193,3 +292,6 @@ fi
 
 # Source the configuration variables
 . ${cwd}/config
+
+CLIENT=${HOST}-fd
+AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer}