#!/bin/sh
#
# Script to automate hardware certification
# This script assumes that everything is in regress/bin and that
# you have an autochanger
#
# This script was designed for Linux. For other systems, you may
#  need to edit it.
#
outf=cert.out
. scripts/functions


echo " " >${outf}
echo "=== Start hardware certification tests at `date +%R:%S` ===" >>${outf}
echo " " >>${outf}
uname -a >>${outf}
echo " " >>${outf}
bin/bareos-dir -t -? >>${outf} 2>>${outf}
echo " " >>${outf}
echo "lsscsi:" >>${outf}
lsscsi >>${outf}
echo " " >>${outf}
echo "Changer=${AUTOCHANGER}" >>${outf}
echo "Drive=${TAPE_DRIVE}" >>${outf}
echo " " >>${outf}
echo "tapeinfo: " >>${outf}
tapeinfo -f ${AUTOCHANGER} >>${outf}
echo " " >>${outf}
echo "loaderinfo: " >>${outf}
loaderinfo -f ${AUTOCHANGER} >>${outf}
echo " " >>${outf}
echo "mtx: " >>${outf}
mtx -f ${AUTOCHANGER} status >>${outf}
echo " " >>${outf}
echo "lspci:" >>${outf}
lspci -vv >>${outf}


# If we have an autoloader, load the tape in slot1
if test ! x$AUTOCHANGER = x/dev/null ; then
   a=`bin/mtx-changer $AUTOCHANGER loaded $SLOT1 $TAPE_DRIVE $DRIVE1`
   if test $a = 0 ; then
      bin/mtx-changer $AUTOCHANGER load $SLOT1 $TAPE_DRIVE $DRIVE1
   fi
fi

# Autochanger tests
REGRESS_DEBUG=1 tests/btape-test-changer >>${outf}
nice tests/2drive-incremental-changer >>${outf}
nice tests/bad-label-changer >>${outf}
nice tests/incremental-changer >>${outf}
nice tests/two-pool-changer >>${outf}
nice tests/two-volume-changer >>${outf}
nice tests/vol-duration-changer >>${outf}



# Non-autochanger tests
REGRESS_DEBUG=1 tests/btape-test-tape >>${outf}
nice tests/ansi-label-tape >>${outf}
nice tests/backup-bareos-tape >>${outf}
nice tests/bscan-tape >>${outf}
nice tests/eighty-simultaneous-jobs-tape >>${outf}
nice tests/eot-fail-tape >>${outf}
nice tests/fixed-block-size-tape >>${outf}
nice tests/four-concurrent-jobs-tape >>${outf}
nice tests/four-jobs-tape >>${outf}
nice tests/incremental-2media-tape >>${outf}
nice tests/incremental-tape >>${outf}
nice tests/memory-bug-tape >>${outf}
nice tests/relabel-tape >>${outf}
nice tests/restore-by-file-tape >>${outf}
nice tests/restore-seek-tape >>${outf}
nice tests/small-file-size-tape >>${outf}
nice tests/truncate-bug-tape >>${outf}
nice tests/verify-vol-tape >>${outf}

# Autochanger tests
REGRESS_DEBUG=1 tests/btape-test-changer >>${outf}
nice tests/2drive-incremental-changer >>${outf}
nice tests/bad-label-changer >>${outf}
nice tests/incremental-changer >>${outf}
nice tests/two-pool-changer >>${outf}
nice tests/two-volume-changer >>${outf}
nice tests/vol-duration-changer >>${outf}


echo "=== End hardware certification tests at `date +%R:%S` ===" >>${outf}
