#
# Cleanup left over files -- both before and after test run
#
+. scripts/functions
scripts/cleanup
-if ! test x@autochanger@ = x/dev/null; then
- drive=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive1@ 1`
- if ! test x$drive = x2; then
- bin/mtx-changer @autochanger@ unload $drive @tape_drive1@ 1
- bin/mtx-changer @autochanger@ load 2 @tape_drive1@ 1
+if test x@autochanger@ != x/dev/null; then
+ slot=`$scripts/@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"
+ $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive1@ 1
+ fi
+ slot=`$scripts/@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"
+ $scripts/@changer_script@ @autochanger@ unload $slot @tape_drive@ 0
fi
- mt -f @tape_drive1@ rewind
- mt -f @tape_drive1@ weof
-fi
-#
-# If we have an autochanger always load tape in slot 1
-#
-if ! test x@autochanger@ = x/dev/null; then
- drive=`bin/mtx-changer @autochanger@ loaded 0 @tape_drive@ 0`
- if ! test x$drive = x1; then
- bin/mtx-changer @autochanger@ unload $drive @tape_drive@ 0
- bin/mtx-changer @autochanger@ load 1 @tape_drive@ 0
+ slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive1@ 1`
+ if test x$slot != x$SLOT2; then
+ echo "load slot $SLOT2 in drive 1"
+ $scripts/@changer_script@ @autochanger@ load $SLOT2 @tape_drive1@ 1
fi
-fi
+ echo "WEOF drive 1"
+ init_drive @tape_drive1@
-mt -f @tape_drive@ rewind
-mt -f @tape_drive@ weof
+ echo "unload slot $SLOT2 in drive 1"
+ $scripts/@changer_script@ @autochanger@ unload $SLOT2 @tape_drive1@ 1
+
+ slot=`$scripts/@changer_script@ @autochanger@ loaded 0 @tape_drive@ 0`
+ echo "Slot $slot in drive 0"
+ if test x$slot != x$SLOT1; then
+ echo "load slot $SLOT1 in drive 0"
+ $scripts/@changer_script@ @autochanger@ load $SLOT1 @tape_drive@ 0
+ fi
+ echo "WEOF drive 0"
+ init_drive @tape_drive@
+
+ echo "unload slot $SLOT1 from drive 0"
+ $scripts/@changer_script@ @autochanger@ unload $SLOT1 @tape_drive@ 0
+fi