#!/bin/ksh
# @(#) $Id$
# ============================================================================
# test routine to run all of the reasonably fast ftt tests.
# it requires no human intervention; however, at the end the
# tape may be unloaded if the user specified "notape"
# ============================================================================

device=${FTT_TAPE:-""}
usage="ftt_fast [-u] [-a] [-p] [devfile]
		-u = do unload test at end (will leave tape unloaded)
		-a = do alignment tests (may cause scsi resets)
		-p = do partition testing
		[devfile] = name of device to use. FTT_TAPE is default"
align=false
unload=false
partition=false

while getopts pau i               # list valid options
do
   case $i in
   u)  unload=true
       ;;
   a)  align=true
       ;;
   p)  partition=true
       ;;
   \?) echo "Usage: $usage"
       exit 2
       ;;
   esac
done
shift `expr $OPTIND - 1`

#===============================================================================
# Get the tape device by looking in $1. If that's not set,
# try FTT_TAPE. If that's not set either, then exit.
export FTT_TAPE
FTT_TAPE=${1:-${FTT_TAPE:-""}}
FTT_TAPE=${FTT_TAPE:?"No device specified"}
#===============================================================================

echo "==============================================================="
echo "doing all of the [reasonably] fast ftt tests using $FTT_TAPE"

if $align
then
   echo "==============================================================="
   echo "align test - may cause scsi resets!"
   echo "==============================================================="
   ${FTT_DIR}/bin/ftt_run_test align
fi
if $partition
then
   echo "==============================================================="
   echo "partition test"
   echo "==============================================================="
   ${FTT_DIR}/bin/ftt_run_test partition
fi
echo "==============================================================="
echo "mode test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test mode

echo "==============================================================="
echo "close test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test close

echo "==============================================================="
echo "label test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test label

echo "==============================================================="
echo "stats test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test stats

echo "==============================================================="
echo "2fm test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test 2fm

echo "==============================================================="
echo "write test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test twrite

echo "==============================================================="
echo "read_only test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test read_only

echo "==============================================================="
echo "verify test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test verify

echo "==============================================================="
echo "position test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test position

echo "==============================================================="
echo "locate test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test locate

echo "==============================================================="
echo "async test"
echo "==============================================================="
${FTT_DIR}/bin/ftt_run_test async

echo "==============================================================="
echo "describe test"
echo "==============================================================="
${FTT_DIR}/ftt_test/scripts/describe

if $unload 
then
   echo "==============================================================="
   echo "notape test"
   echo "==============================================================="
  ${FTT_DIR}/bin/ftt_run_test notape
fi
