From b89a6fde3640853c028700b02dcdd9cdace0989a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 1 Jun 2008 20:05:15 +0000 Subject: [PATCH] Cleanup some autochanger code git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7088 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/scripts/cleanup-2tape.in | 26 +------------------------- regress/scripts/cleanup-tape.in | 23 +++++++++++++++-------- regress/scripts/functions | 1 + regress/scripts/prepare-two-tapes.in | 6 ++++++ regress/tests/two-volume-changer | 6 ++---- 5 files changed, 25 insertions(+), 37 deletions(-) diff --git a/regress/scripts/cleanup-2tape.in b/regress/scripts/cleanup-2tape.in index b937ea115e..8fa197d4df 100755 --- a/regress/scripts/cleanup-2tape.in +++ b/regress/scripts/cleanup-2tape.in @@ -6,28 +6,4 @@ . scripts/functions scripts/cleanup - -if test x@autochanger@ != x/dev/null; then - slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT2"; then - bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 - bin/@changer_script@ @autochanger@ load $SLOT2 @tape_drive@ $DRIVE1 - fi - - init_drive @tape_drive@ -fi - - -# -# If we have an autochanger always load tape in slot 1 -# -if test x@autochanger@ != x/dev/null; then - slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` - if test "x${slot}" != "x$SLOT1"; then - bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 - bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 - fi -fi - -init_drive @tape_drive@ - +scripts/prepare-two-tapes diff --git a/regress/scripts/cleanup-tape.in b/regress/scripts/cleanup-tape.in index ce996089c3..936540289d 100755 --- a/regress/scripts/cleanup-tape.in +++ b/regress/scripts/cleanup-tape.in @@ -1,19 +1,26 @@ #!/bin/sh # -# Cleanup left over files -- both before and after test run +# Cleanup left over files, then load $SLOT1 into drive and +# write an EOF on it. # . scripts/functions scripts/cleanup -if test "x@autochanger@" != "x/dev/null" ; then - a=`bin/@changer_script@ @autochanger@ loaded $SLOT1 @tape_drive@ 0` - if test $a = 0 ; then - bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ 0 - fi +if test x@autochanger@ != x/dev/null; then + slot=`bin/@changer_script@ @autochanger@ loaded 0 @tape_drive@ $DRIVE1` + case $slot in + 0) + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + ;; + $SLOT1) + ;; + default) + bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + ;; + esac fi init_drive @tape_drive@ - - diff --git a/regress/scripts/functions b/regress/scripts/functions index 6ddd0570c5..61d6eb4999 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -282,3 +282,4 @@ fi . ${cwd}/config CLIENT=${HOST}-fd +AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer} diff --git a/regress/scripts/prepare-two-tapes.in b/regress/scripts/prepare-two-tapes.in index 65bcce823c..642a8f850c 100755 --- a/regress/scripts/prepare-two-tapes.in +++ b/regress/scripts/prepare-two-tapes.in @@ -28,6 +28,12 @@ if test x@autochanger@ != x/dev/null; then init_drive @tape_drive@ slot=$SLOT2 ;; + default) + bin/@changer_script@ @autochanger@ unload $slot @tape_drive@ $DRIVE1 + bin/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ $DRIVE1 + init_drive @tape_drive@ + slot=$SLOT1 + ;; esac # init the other slot diff --git a/regress/tests/two-volume-changer b/regress/tests/two-volume-changer index e9e48d2760..e775a7bf79 100755 --- a/regress/tests/two-volume-changer +++ b/regress/tests/two-volume-changer @@ -33,7 +33,7 @@ messages @$out tmp/log1.out label storage=DDS-4 volume=TestVolume001 slot=$SLOT1 pool=Default drive=$DRIVE1 label storage=DDS-4 volume=TestVolume002 slot=$SLOT2 pool=Default drive=$DRIVE1 -update Volume=TestVolume001 MaxVolBytes=3000000 pool=Default drive=0 +update Volume=TestVolume001 MaxVolBytes=3000000 pool=Default drive=$DRIVE1 sql select * from Storage; select VolumeName,InChanger,Slot,StorageId from Media; @@ -54,9 +54,7 @@ run_bacula check_for_zombie_jobs storage=DDS-4 stop_bacula -mt -f ${TAPE_DRIVE} rewind -mtx -f ${AUTOCHANGER} unload -sleep 15 +bin/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $SLOT2 ${TAPE_DRIVE} 0 cat <tmp/bconcmds @$out /dev/null -- 2.39.5