blob: 1b59fcd639209891d7715e1dfb0b6f4be31f577b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#! /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
|