]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/scripts/functions
Check for file count mismatch
[bacula/bacula] / regress / scripts / functions
index 3e1c468e179d224d274fda5b75089c757a5c44b3..28c85f3a77cc3cc612b7cffe38b1463095f1af81 100644 (file)
@@ -6,11 +6,25 @@ start_test()
 {
    echo " "
    echo " "
-   echo " === Starting $JobName at `date +%R:%S` ==="
-   echo " === Starting $JobName at `date +%R:%S` ===" >>working/log
+   echo " === Starting $TestName at `date +%R:%S` ==="
+   echo " === Starting $TestName at `date +%R:%S` ===" >>working/log
    echo " "
 }
 
+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
+}
+
+
 set_debug()
 {
    debug=$1
@@ -23,8 +37,11 @@ set_debug()
 
 run_bacula()
 {
+   debug_wait
    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
@@ -41,6 +58,25 @@ run_bconsole()
    fi
 }
 
+run_btape()
+{
+   if test "$debug" -eq 1 ; then
+     cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
+   else
+     cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
+   fi
+}
+
+run_bscan()
+{
+   if test "$debug" -eq 1 ; then
+      bin/bscan $* | tee tmp/log.out
+   else
+      bin/bscan $* 2>&1 >/dev/null
+   fi
+}
+
+
 stop_bacula()
 {
    bin/bacula stop 2>&1 >/dev/null
@@ -48,15 +84,23 @@ stop_bacula()
 
 check_for_zombie_jobs()
 {
-   scripts/check_for_zombie_jobs $1
+   scripts/check_for_zombie_jobs $*
 }
 
 change_jobname()
 {
+   if test $# -eq 1; then
+      oldname=NightlySave
+      newname=$1
+   else
+      oldname=$1
+      newname=$2
+   fi
    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
+   echo "s%${oldname}%${newname}%g" >tmp/1
+   sed -f tmp/1 bin/1 >bin/bacula-dir.conf
+#  echo "Job ${oldname} changed to ${newname}"
 }
 
 check_two_logs()
@@ -65,6 +109,10 @@ check_two_logs()
    bstat=$?
    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
 }
 
 check_restore_diff()
@@ -84,19 +132,54 @@ end_test()
    if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
       echo " "
       echo " "
-      echo "  !!!!! $TestName Bacula source failed!!! !!!!! "
+      echo "  !!!!! $TestName 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
+         echo "        bstat=$bstat rstat=$rstat dstat=$dstat"
       else
          echo "  !!!!! Restored files differ          !!!!! "
          echo "  !!!!! Restored files differ          !!!!! " >>test.out
+         echo "        bstat=$bstat rstat=$rstat dstat=$dstat"
       fi
       echo " "
    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
 }
+
+copy_tape_confs()
+{
+   scripts/copy-tape-confs
+   scripts/cleanup-tape
+}
+
+copy_test_confs()
+{
+   scripts/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
+}
+
+# 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