summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/run_scenarios
blob: 86f0f8d93c9c3df5511fcc3aae017dd13fc9684c (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
#! /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

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
  SCENARIOS=
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 `ls -1 ${SCENARIOS}`
do
  base=`echo ${scenario} | sed -s 's/\.scen$//'`
  expected=${base}.expected
  output=${base}.output
  vecho Running ${scenario}
  ${schedsim} $scenario  >${output}
  if [ -r ${expected} ] ; then
    diff ${output} ${expected} >/dev/null
    if [ $? -ne 0 ] ; then
      echo "FAIL - ${scenario}"
      echo "    diff ${output} ${expected} "
    else
      echo "PASS - ${scenario}"
    fi
  else
      echo "UNKNOWN - ${scenario}"
      echo "    cp ${output} ${expected} "
  fi
done