blob: 1b59fcd639209891d7715e1dfb0b6f4be31f577b (
plain) (
tree)
|
|
#! /bin/sh
#
fatal()
{
echo "$*"
exit 1
}
toggle()
{
case $1 in
no) echo "yes" ;;
yes) echo "no" ;;
*) fatal "Unknown value to toggle ($1)" ;;
esac
}
usage()
{
cat <<EOF
run_scenarios [options]
-s - specify scheduler simulator executable (REQUIRED)
-S - specify scenario base direcroty (./scenarios assumed)
-1 - toggle running single CPU scenarios (default=no)
-4 - toggle running four CPU scenarios (default=no)
-A - toggle all scenario flags
-v - toggle verbose output (default=no)
EOF
}
vecho()
{
if [ ${verbose} = "yes" ] ; then
echo "$*"
fi
}
verbose=no
do_all=no
do_one=no
do_four=no
schedsim=
scenarios_dir=.
while getopts vs:AS:14 OPT
do
case "$OPT" in
v) verbose=`toggle ${verbose}` ;;
s) schedsim=${OPTARG} ;;
A) do_all=`toggle ${do_all}` ;;
S) scenarios_dir=${OPTARG} ;;
1) do_one=`toggle ${do_one}` ;;
4) do_four=`toggle ${do_four}` ;;
*) usage; exit 1;
esac
done
shiftcount=`expr $OPTIND - 1`
shift $shiftcount
args=$*
if [ "X${schedsim}" != "X" ] ; then
type ${schedsim} >/dev/null 2>&1 || fatal ${schedsim} not found
else
fatal "schedsim binary must be specified with -s option"
fi
scen=${scenarios_dir}/scenarios
test -d ${scen}|| \
fatal ${scen} directory is not present
if [ ${do_all} = "yes" ]; then
SCENARIOS="${scen}/*.scen"
else
for i in $*
do
SCENARIOS="${SCENARIOS} ${scen}/${i}"
done
fi
if [ ${do_one} = "yes" ]; then
SCENARIOS="${SCENARIOS} ${scen}/cpus1*.scen"
fi
if [ ${do_four} = "yes" ]; then
SCENARIOS="${SCENARIOS} ${scen}/cpus4*.scen"
fi
test "X${SCENARIOS}" = "X" && fatal "No scenarios specified"
for scenario in ${SCENARIOS}
do
test -r ${scenario} || fatal "Scenario ${scenario} not found!"
done
scenarios=0
passed=0
failed=0
for scenario in ${SCENARIOS}
do
base=`echo ${scenario} | sed -s 's/\.scen$//'`
expected=${base}.expected
output=${base}.output
vecho Running ${scenario}
run=`expr ${run} + 1`
${schedsim} $scenario >${output}
if [ $? -ne 0 ] ; then
failed=`expr ${failed} + 1`
echo "FAIL - ${scenario}"
elif [ -r ${expected} ] ; then
diff ${output} ${expected} >/dev/null
if [ $? -ne 0 ] ; then
failed=`expr ${failed} + 1`
echo "FAIL - ${scenario}"
echo " diff ${output} ${expected} "
else
passed=`expr ${passed} + 1`
echo "PASS - ${scenario}"
fi
else
echo "UNKNOWN - ${scenario}"
fi
done
echo "=== Test report for `basename ${schedsim}`"
echo "Run: " ${run}
echo "Passed: " ${passed}
echo "Failed: " ${failed}
exit 0
|