]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Prepare 2.2 for faketape testing
authorEric Bollengier <eric@eb.homelinux.org>
Sat, 31 May 2008 12:51:01 +0000 (12:51 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Sat, 31 May 2008 12:51:01 +0000 (12:51 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7072 91ce42f0-d328-0410-95d8-f526ca767f89

regress/scripts/bacula-sd-2d.conf.in
regress/scripts/bacula-sd-2drive.conf.in
regress/scripts/bacula-sd-2tape.conf.in
regress/scripts/cleanup-2drive.in
regress/scripts/cleanup-2tape.in
regress/scripts/cleanup-tape.in
regress/scripts/create_sed
regress/scripts/do_sed
regress/scripts/functions
regress/scripts/prepare-fake-autochanger.in [new file with mode: 0644]

index 466b68fcc6f2689c665780162cde2916783fc2a9..bb80a48ebbc1419e1dea4e730c04223eb5d93f92 100644 (file)
@@ -31,7 +31,7 @@ Director {
 Autochanger {
   Name = DDS-4
   Changer Device = @autochanger@
-  Changer Command ="@scriptdir@/mtx-changer %c %o %S %a %d"
+  Changer Command ="@scriptdir@/@changer_script@ %c %o %S %a %d"
   Device = Drive-0         
 }
 
index 8ee4dbd62931174ae554df3d72def4d38eaa4d54..12d2e8d6c755470ea441d1da070eb77d5ed64e9b 100644 (file)
@@ -34,7 +34,7 @@ Director {
 Autochanger {
   Name = DDS-4
   Changer Device = @autochanger@
-  Changer Command ="@scriptdir@/mtx-changer %c %o %S %a %d"
+  Changer Command ="@scriptdir@/@changer_script@ %c %o %S %a %d"
   Device = Drive-0, Drive-1
 }
 
index 4abd813945389be800295f56f9c914da9831f8d7..07a50c4085b30c429339e6a103bc4c28284bad0a 100644 (file)
@@ -34,7 +34,7 @@ Director {
 Autochanger {
   Name = DDS-4
   Changer Device = @autochanger@
-  Changer Command ="@scriptdir@/mtx-changer %c %o %S %a %d"
+  Changer Command ="@scriptdir@/@changer_script@ %c %o %S %a %d"
   Device = Drive-0
 }
 
index 32b27c019e0fd439ce706fa2ee805d93dde619c2..2e485e82a9cf57778fb2878b7b7f176e79926e52 100755 (executable)
@@ -5,40 +5,40 @@
 scripts/cleanup
 
 if test x@autochanger@ != x/dev/null; then
-   slot=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive1@ 1`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive1@ 1`
    echo "Slot $slot in drive 1"
    if test x$slot != x0 ; then
       echo "unload slot $slot in drive 1"
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive1@ 1
+      bin/@changer_script@ @autochanger@ unload $slot @tape_drive1@ 1
    fi
-   slot=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive@ 0`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ 0`
    echo "Slot $slot in drive 0"
    if test x$slot != x0 ; then
       echo "unload slot $slot in drive 0"
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ 0
+      bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ 0
    fi
 
 
-   slot=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive1@ 1`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive1@ 1`
    if test x$slot != x2; then
       echo "load slot 2 in drive 1"
-      bin/mtx-changer @autochanger@ load 2 @tape_drive1@ 1
+      bin/@changer_script@ @autochanger@ load 2 @tape_drive1@ 1
    fi
    echo "WEOF drive 1"
-   mt -f @tape_drive1@ rewind
-   mt -f @tape_drive1@ weof
+   init_drive @tape_drive1@
+
    echo "unload slot 2 in drive 1"
-   bin/mtx-changer @autochanger@ unload 2 @tape_drive1@ 1
+   bin/@changer_script@ @autochanger@ unload 2 @tape_drive1@ 1
 
-   slot=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive@ 0`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ 0`
    echo "Slot $slot in drive 0"
    if test x$slot != x1; then
       echo "load slot 1 in drive 0"
-      bin/mtx-changer @autochanger@ load 1 @tape_drive@ 0
+      bin/@changer_script@ @autochanger@ load 1 @tape_drive@ 0
    fi
    echo "WEOF drive 0"
-   mt -f @tape_drive@ rewind
-   mt -f @tape_drive@ weof
+   init_drive @tape_drive@
+
    echo "unload slot 1 from drive 0"
-   bin/mtx-changer @autochanger@ unload 1 @tape_drive@ 0
+   bin/@changer_script@ @autochanger@ unload 1 @tape_drive@ 0
 fi
index 28eea0b59314231ce85ed090d7db065d9d3ca62b..b937ea115ee900b0cadb23dddcd035127416837a 100755 (executable)
@@ -8,13 +8,13 @@
 scripts/cleanup
 
 if test x@autochanger@ != x/dev/null; then
-   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
    if test "x${slot}" != "x$SLOT2"; then
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
-      bin/mtx-changer @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
+      bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
    fi
-   mt -f @tape_drive@ rewind
-   mt -f @tape_drive@ weof
+
+   init_drive @tape_drive@
 fi
 
 
@@ -22,12 +22,12 @@ fi
 # If we have an autochanger always load tape in slot 1
 #
 if test x@autochanger@ != x/dev/null; then
-   slot=`bin/mtx-changer @autochanger@ loaded 0 dummy $DRIVE1`
+   slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
    if test "x${slot}" != "x$SLOT1"; then
-      bin/mtx-changer @autochanger@ unload $slot @tape_drive@ $DRIVE1
-      bin/mtx-changer @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
    fi
 fi
 
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
+init_drive @tape_drive@
+
index e5ebe56344bf27fbea19c4f949826f96f5c06915..310731c9173ec0a9e3d0485754e38b9e6ea2474e 100755 (executable)
@@ -2,15 +2,16 @@
 #
 # Cleanup left over files -- both before and after test run
 #
-. ./config
+. scripts/functions
 
 scripts/cleanup
 
 if test "x@autochanger@" != "x/dev/null" ; then
-   a=`bin/mtx-changer @autochanger@ loaded $SLOT1 @tape_drive@ 0`
+   a=`bin/@changer_script@ @autochanger@ loaded $SLOT1 @tape_drive@ 0`
    if test $a = 0 ; then
-     bin/mtx-changer @autochanger@ load $SLOT1 @tape_drive@ 0
+     bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ 0
    fi
 fi
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
+
+init_drive @tape_drive@
+
index f672ecc4fd69c372efc156077c538195bd2200b5..c89bf485aef11d4b9ffab8f234b16922ec7df462 100755 (executable)
@@ -10,6 +10,7 @@ out="${cwd}/tmp/sed_tmp"
 
 # set the ports used by these tests
 BASEPORT=${BASEPORT:-8101}
+AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer}
 srcdir=${BACULA_SOURCE}
 dirport=${BASEPORT}
 fdport=`expr ${BASEPORT} '+' 1`
@@ -28,6 +29,7 @@ echo "s%@subsysdir@%${cwd}/working%g" >>${out}
 echo "s%@job_email@%${EMAIL}%g" >>${out}
 echo "s%@tape_drive@%${TAPE_DRIVE}%g" >>${out}
 echo "s%@autochanger@%${AUTOCHANGER}%g" >>${out}
+echo "s%@changer_script@%${AUTOCHANGER_SCRIPT}%g" >>${out}
 echo "s%@tmpdir@%${cwd}/tmp%g" >>${out}
 echo "s%@hostname@%${HOST}%g" >>${out}
 echo "s%@changer_path@%${AUTOCHANGER_PATH}%g" >>${out}
index 902f989af44b651a050011402190ad9dae039a77..2236d496752c307eebd8fcc5cb882c80b43e70d4 100755 (executable)
@@ -37,6 +37,7 @@ sed -f ${out} ${cwd}/scripts/cleanup-tape.in >${cwd}/scripts/cleanup-tape
 sed -f ${out} ${cwd}/scripts/cleanup-2tape.in >${cwd}/scripts/cleanup-2tape
 sed -f ${out} ${cwd}/scripts/cleanup-2drive.in >${cwd}/scripts/cleanup-2drive
 sed -f ${out} ${cwd}/scripts/prepare-two-tapes.in >${cwd}/scripts/prepare-two-tapes
+sed -f ${out} ${cwd}/scripts/prepare-fake-autochanger.in >${cwd}/scripts/prepare-fake-autochanger
 sed -f ${out} ${cwd}/scripts/bacula-dir.conf.testrunscript.in >${cwd}/scripts/bacula-dir.conf.testrunscript
 
 sed -f ${out} ${cwd}/scripts/tls-bacula-fd.conf.in >${cwd}/scripts/tls-bacula-fd.conf
index ec5d4d36678f964ca43dd355dea837da5876ac1c..11c3789623567ec068f760da1c9787241024ce7d 100644 (file)
@@ -55,6 +55,13 @@ if test x${AUTOCHANGER} = x/dev/null ; then
 fi
 }
 
+require_faketape()
+{
+if test x${USE_FAKETAPE} = x ; then
+   echo "$TestName test needs the faketape driver."
+   exit 1
+fi
+}
 
 skip_if_no_autochanger()
 {
@@ -237,6 +244,16 @@ debug_wait()
   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
diff --git a/regress/scripts/prepare-fake-autochanger.in b/regress/scripts/prepare-fake-autochanger.in
new file mode 100644 (file)
index 0000000..799dbd2
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# This script will prepare a big dummy autochanger 
+#
+
+. scripts/functions
+
+# check if user wants to run this test
+if test x$USE_FAKETAPE = x; then
+    exit 1
+fi
+
+adir=@working_dir@/ach
+
+mkdir $adir 2> /dev/null
+rm -f $adir/log $adir/barcodes $adir/load* $adir/slot* $adir/drive* 2> /dev/null
+
+# create the autochanger configuration file
+cat > $adir/conf <<EOF
+maxdrive=8
+maxslot=80
+dbgfile=$adir/log
+EOF
+
+# turn on ach debug
+touch $adir/log
+
+# create 75 volumes
+for i in `seq 1 75`; do
+    echo $i:vol$i >> $adir/barcodes
+    cp /dev/null $adir/slot$i
+done
+
+# make a cleaning tape
+echo 76:CLN01 >> $adir/barcodes
+cp /dev/null $adir/slot76
+
+# keep other empty
+for i in `seq 77 79`; do
+    echo $i:  >> $adir/barcodes
+done
+