]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/scripts/prepare-two-tapes.in
Add new maxruntime test -- not yet working
[bacula/bacula] / regress / scripts / prepare-two-tapes.in
index f31c0abe557df188a65562742d5e86879350714d..5d06bdca463e8ec4827ed5f29cb202a6617127c9 100755 (executable)
@@ -1,13 +1,56 @@
 #!/bin/sh
 #
-# Create two blank tapes
-#
-@changer_path@ -f @autochanger@ unload
-@changer_path@ -f @autochanger@ load 1
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
-@changer_path@ -f @autochanger@ unload
-@changer_path@ -f @autochanger@ load 2
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
-#@changer_path@ -f @autochanger@ unload
+# Cleanup left over files -- both before and after test run
+#
+# Write an EOF on tape in slot $SLOT1  and  on tape in $SLOT2
+
+. scripts/functions
+
+scripts/cleanup
+
+
+# with disk-changer, we have to initialize slots
+init_slot @tape_drive@ $SLOT1
+init_slot @tape_drive@ $SLOT2
+
+#
+# init first of two slots
+# optimize so we don't unnecessarily unload and load slots
+#
+if test x@autochanger@ != x/dev/null; then
+   slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1`
+   case $slot in
+   0)
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      slot=$SLOT1
+      ;;
+   $SLOT1)
+      slot=$SLOT1
+      ;;
+   $SLOT2)
+      slot=$SLOT2
+      ;;
+   *)
+      $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      slot=$SLOT1
+      ;;
+  esac
+  init_drive @tape_drive@
+  $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1
+
+
+# init the other slot
+  case $slot in
+   $SLOT1)
+      $scripts/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1
+      ;;
+   $SLOT2)
+      $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1
+      ;;
+   *)
+      echo "Something went wrong. Expected $SLOT1 or $SLOT2, got $slot"
+      exit 1
+   esac
+   init_drive @tape_drive@
+fi