source: rtems-schedsim/schedsim/shell/run_scenarios @ d36a128

Last change on this file since d36a128 was d36a128, checked in by Joel Sherrill <joel.sherrill@…>, on 05/26/14 at 22:24:17

make check now works and reports pass/fail

  • Property mode set to 100755
File size: 2.6 KB
Line 
1#! /bin/sh
2#
3
4fatal()
5{
6  echo "$*"
7  exit 1
8}
9
10toggle()
11{
12  case $1 in
13    no)  echo "yes" ;;
14    yes) echo "no" ;;
15    *)   fatal "Unknown value to toggle ($1)" ;;
16  esac
17}
18
19usage()
20{
21cat <<EOF
22run_scenarios [options]
23  -s         - specify scheduler simulator executable (REQUIRED)
24  -S         - specify scenario base direcroty (./scenarios assumed)
25  -1         - toggle running single CPU scenarios (default=no)
26  -4         - toggle running four CPU scenarios (default=no)
27  -A         - toggle all scenario flags
28  -v         - toggle verbose output (default=no)
29EOF
30}
31
32vecho()
33{
34  if [ ${verbose} = "yes" ] ; then
35    echo "$*"
36  fi
37}
38
39verbose=no
40do_all=no
41do_one=no
42do_four=no
43schedsim=
44scenarios_dir=.
45
46while getopts vs:AS:14 OPT
47do
48  case "$OPT" in
49    v) verbose=`toggle ${verbose}` ;;
50    s) schedsim=${OPTARG} ;;
51    A) do_all=`toggle ${do_all}`   ;;
52    S) scenarios_dir=${OPTARG}   ;;
53    1) do_one=`toggle ${do_one}`   ;;
54    4) do_four=`toggle ${do_four}` ;;
55    *) usage; exit 1;
56  esac
57done
58
59shiftcount=`expr $OPTIND - 1`
60shift $shiftcount
61
62args=$*
63
64if [ "X${schedsim}" != "X" ] ; then
65  type ${schedsim} >/dev/null 2>&1 || fatal ${schedsim} not found
66else
67  fatal "schedsim binary must be specified with -s option"
68fi
69
70scen=${scenarios_dir}/scenarios
71test -d ${scen}|| \
72    fatal ${scen} directory is not present
73
74if [ ${do_all} = "yes" ]; then
75  SCENARIOS="${scen}/*.scen"
76else
77  for i in $*
78  do
79    SCENARIOS="${SCENARIOS} ${scen}/${i}"
80  done
81fi
82
83if [ ${do_one} = "yes" ]; then
84  SCENARIOS="${SCENARIOS} ${scen}/cpus1*.scen"
85fi
86
87if [ ${do_four} = "yes" ]; then
88  SCENARIOS="${SCENARIOS} ${scen}/cpus4*.scen"
89fi
90
91test "X${SCENARIOS}" = "X" && fatal "No scenarios specified"
92
93for scenario in ${SCENARIOS}
94do
95  test -r ${scenario} || fatal "Scenario ${scenario} not found!"
96done
97
98scenarios=0
99passed=0
100failed=0
101for scenario in ${SCENARIOS}
102do
103  base=`echo ${scenario} | sed -s 's/\.scen$//'`
104  expected=${base}.expected
105  output=${base}.output
106  vecho Running ${scenario}
107  run=`expr ${run} + 1`
108  ${schedsim} $scenario  >${output}
109  if [ $? -ne 0 ] ; then
110    failed=`expr ${failed} + 1`
111    echo "FAIL - ${scenario}"
112  elif [ -r ${expected} ] ; then
113    diff ${output} ${expected} >/dev/null
114    if [ $? -ne 0 ] ; then
115      failed=`expr ${failed} + 1`
116      echo "FAIL - ${scenario}"
117      echo "    diff ${output} ${expected} "
118    else
119      passed=`expr ${passed} + 1`
120      echo "PASS - ${scenario}"
121    fi
122  else
123    echo "UNKNOWN - ${scenario}"
124  fi
125done
126
127echo "=== Test report for `basename ${schedsim}`"
128echo "Run:    " ${run}
129echo "Passed: " ${passed}
130echo "Failed: " ${failed}
131
132exit 0
Note: See TracBrowser for help on using the repository browser.