#!/bin/bash
#Usage: ./tiobench.pl [<options>]
#Available options:
#        [--help] (this help text)
#        [--identifier IdentString] (use IdentString as identifier in output)
#        [--nofrag] (don't write fragmented files)
#        [--size SizeInMB]+
#        [--numruns NumberOfRuns]+
#        [--dir TestDir]+
#        [--block BlkSizeInBytes]+
#        [--random NumberRandOpsPerThread]+
#        [--threads NumberOfThreads]+
#
. /etc/autobench.conf || . functions

# Install support files ######################################################
if [ ! \( -d $AUTODIR/sources/tiobench -a -x $AUTODIR/sources/tiobench/tiobench.pl \) ];
then
  log "Installing tio benchmark"
  $AUTODIR/scripts/benchmarks/install/tio || exit 2
fi

getcommand doprofilers
doprofilers install

touch $LOGDIR/benchmark/tioout.$RUN_NUMBER
echo $* > $LOGDIR/benchmark/tio_cmd.$RUN_NUMBER
read line < $LOGDIR/benchmark/tio_cmd.$RUN_NUMBER
echo $line
mp=${line##*--dir}
echo $mp
mp=${mp%%--*}
echo $mp
fst=`mount | grep $mp`
fst=${fst##*type}
echo $fst
fst=${fst%%(*}
echo fstype is $fst
echo $fst > $LOGDIR/benchmark/fstype.$RUN_NUMBER
if [ "$fst" == "" ]; then
	log "No filesystem mounted to run test on, aborting!"
	exit
fi

startprofilers

$AUTODIR/sources/tiobench/tiobench.pl $* | tee $LOGDIR/benchmark/tioout.$RUN_NUMBER

stopprofilers
doprofilers report
doprofilers postprocess

