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

Last change on this file since c552573 was c552573, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 23, 2011 at 8:28:41 PM

2011-06-23 Joel Sherrill <joel.sherrill@…>

  • run_scenarios: Improve error checking.
  • Property mode set to 100755
File size: 1.9 KB
Line 
1#! /bin/sh
2#
3#  $Id$
4#
5
6fatal()
7{
8  echo "$*"
9  exit 1
10}
11
12toggle()
13{
14  case $1 in
15    no)  echo "yes" ;;
16    yes) echo "no" ;;
17    *)   fatal "Unknown value to toggle ($1)" ;;
18  esac
19}
20
21usage()
22{
23cat <<EOF
24run_scenarios [options]
25  -1         - toggle running single CPU scenarios (default=no)
26  -4         - toggle running four CPU scenarios (default=no)
27  -A         - toggle all scenario flags
28EOF
29}
30
31vecho()
32{
33  if [ ${verbose} = "yes" ] ; then
34    echo "$*"
35  fi
36}
37
38verbose=no
39do_all=no
40do_one=no
41do_four=no
42schedsim_dir=
43
44while getopts vd:A14 OPT
45do
46  case "$OPT" in
47    v) verbose=`toggle ${verbose}` ;;
48    d) schedsim_dir=${OPTARG} ;;
49    A) do_all=`toggle ${do_all}`   ;;
50    1) do_one=`toggle ${do_one}`   ;;
51    4) do_four=`toggle ${do_four}` ;;
52    *) usage; exit 1;
53  esac
54done
55
56if [ "X${schedsim_dir}" != "X" ] ; then
57  test -d ${schedsim_dir} || fatal ${schedsim_dir} is not readable
58  schedsim_dir=${schedsim_dir}/
59else
60  fatal "schedsim binary directory must be specified with -d option"
61fi
62
63test -d scenarios || fatal scenarios directory is not present
64
65if [ ${do_all} = "yes" ]; then
66  SCENARIOS="scenarios/*.scen"
67else
68  SCENARIOS=
69fi
70
71if [ ${do_one} = "yes" ]; then
72  SCENARIOS="${SCENARIOS} scenarios/cpus1*.scen"
73fi
74
75if [ ${do_four} = "yes" ]; then
76  SCENARIOS="${SCENARIOS} scenarios/cpus4*.scen"
77fi
78
79test "X${SCENARIOS}" = "X" && fatal "No scenarios specified"
80
81for scenario in `ls -1 ${SCENARIOS}`
82do
83  base=`echo ${scenario} | sed -s 's/\.scen$//'`
84  expected=${base}.expected
85  output=${base}.output
86  vecho Running ${scenario}
87  ${schedsim_dir}/schedsim $scenario  >${output}
88  if [ -r ${expected} ] ; then
89    diff ${output} ${expected} >/dev/null
90    if [ $? -ne 0 ] ; then
91      echo "FAIL - ${scenario}"
92      echo "    diff ${output} ${expected} "
93    else
94      echo "PASS - ${scenario}"
95    fi
96  else
97      echo "UNKNOWN - ${scenario}"
98      echo "    cp ${output} ${expected} "
99  fi
100done
101
102
Note: See TracBrowser for help on using the repository browser.