#! /bin/csh -f
#
#  Run iorate tests
#
# $Header: /home/westiv/iorate/RCS/run_test,v 3.0 2011/06/18 14:30:35 westiv Exp $
#

#
#  Adding various device and test files will vary the testing run here.
#  Just add the file names to the 'devs' and 'tests' list varaibles.
#  Device file, test file, or archive directory names with spaces will
#  NOT work well with this script.
#
#  Using the 'cycle' script to run this over and over again works well.
#

# List of device files to test against
set devs = ( devices )

# List of test files to use on all device files
set tests = ( tests )

# List of IOPS targets to use - after running full speed
set iops_opts = ( 40 65 80 90 95  )

# Archive directory to place the results in
set archive = data

# Name of the iops that we generate after each full speed test
set iops_file = iops.ior

# Set silent mode - only warnings and errors are visible
set silent = -s


# Note which run we are doing
@ count = `cat run_test.count` + 1
echo $count > run_test.count

# Make the archive space if needed
if ( ! -d $archive ) then
    mkdir $archive
endif

# Log the start
date +"Starting io test pass "$count" at %T on %A, %B %e, %Y" | tee -a run_test.log

# In case silent is not set, make sure it is defined
if ( ! $?silent ) set silent = ""

# Run each device file
foreach dev ( $devs )

# Run each test file
    foreach test ( $tests )

	set target = ( $silent -f $dev".ior" -t $test".ior" )

	set out = $archive"/"$dev"-"$test".full."$count

#   Run the full speed test
	./iorate $target -o $out |& tee -a $archive"/run_test."$count".log"

	echo "Generating IOPS baseline data"
	awk -f gen_iops.awk < $out".perf" > $iops_file

	foreach iops ( $iops_opts )

	    set out = $archive"/"$dev"-"$test"."$iops"."$count

#    Run the slowed test
	    ./iorate $target -i $iops_file -r $iops -o $out |& tee -a $archive"/run_test."$count".log"

	end

    end

end

# Note we are done
date +"Finished pass "$count" at %T on %A, %B %e, %Y" | tee -a run_test.log

