source: rtems-testing/sim-scripts/gdb-sim-run.in @ 450998b

4.11
Last change on this file since 450998b was 450998b, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 19, 2009 at 10:37:10 PM

2009-01-19 Joel Sherrill <joel.sherrill@…>

  • ChangeLog?, Makefile, README, gdb-sim-run.in, jmr3904.in, usleep.c: New files.
  • Property mode set to 100755
File size: 5.0 KB
Line 
1#! /bin/sh
2#
3#  Framework script tailored for the @CPU@/@BSP
4#
5#  NOTE: If the does not have the name of a specific CPU/BSP pair, then
6#        this is the source file.  If it does have specific CPU/BSP pair,
7#        then this is generated output and should NOT be edited.
8
9#  $Id$
10#
11
12trap "test_exit 1" 1 2 3 13 14 15
13
14test_exit()
15{
16  exit_code=$1
17  exit $exit_code
18}
19
20
21progname=${0##*/}        # fast basename hack for ksh, bash
22
23USAGE=\
24"usage: $progname [ -opts ] test [ test ... ]
25        -v         -- verbose
26        -c         -- enabled coverage (not supported by all BSPs)
27        -i         -- interactive (no time limit)
28        -l limit   -- specify time limit (default is 'BSP dependent')
29"
30
31#   log an error to stderr
32prerr()
33{
34    echo "$*" >&2
35}
36
37fatal() {
38    [ "$1" ] && prerr $*
39    prerr "$USAGE"
40    exit 1
41}
42
43warn() {
44    [ "$1" ] && prerr $*
45}
46
47#
48# process the options
49#
50# defaults for getopt vars
51#
52
53coverage="no"
54verbose="no"
55limit="not_set"
56interactive="no"
57
58while getopts vil: OPT
59do
60    case "$OPT" in
61        v) verbose="yes";;
62        c) coverage="yes";;
63        i) interactive="yes";;
64        l) limit="$OPTARG";;
65        *) fatal;;
66    esac
67done
68shiftcount=`expr $OPTIND - 1`
69shift $shiftcount
70
71if [ ${interactive} = "yes" ] ; then
72  limit=0
73fi
74
75args=$*
76
77### Set BSP defaults.  If BSP does not have default, it will override
78bspRunFatal="no"
79bspGeneratesDeviceTree="no"
80
81rtemsVersion=`echo ${progname} | sed -e 's/@BSP@-//' -e 's/-gdb//'`
82RUN=@CPU_TARGET@-rtems${rtemsVersion}-run
83
84###################################################################
85###################################################################
86###################################################################
87##INSERT BSP SUPPORT HERE
88###################################################################
89###################################################################
90###################################################################
91
92## These are faults any BSP may generate.  They are common to RTEMS.
93checkGenericFaults()
94{
95  logfile=$1
96
97  grep "Suspending faulting task" ${logfile}
98  Fault=$?
99  grep "assertion failed" ${logfile}
100  Assert=$?
101  if [ $Fault -eq 0 -o $Assert -eq 0 ] ; then
102    return 1
103  fi
104  return 0
105}
106
107runtest()
108{
109  testname=${1}
110  testtype=${2}
111  max_run_time=${3}
112  if [ ${max_run_time} -eq 0 ] ; then
113    #echo run ${testname} forever
114    runBSP ${testname}
115    return
116  fi
117
118  #echo run ${testname} for maximum ${max_run_time} seconds
119  logfile=${testname}.tmp
120  runBSP ${testname} >${logfile} 2>&1 &
121  pid=$!
122
123  # Make sure it won't run forever...
124  millilimit=`expr ${max_run_time} \* 1000`
125  milliseconds=0
126  while :
127  do
128    # sleep 10ms at a time waiting for job to finish or timer to expire
129    # if job has exited, then we exit, too.
130    usleep 10000  # ten milliseconds
131    milliseconds=`expr ${milliseconds} + 10`
132    kill -0 $pid 2> /dev/null
133    running=$?
134    if [ $running -eq 0 ] ; then
135      if [ ${milliseconds} -ge ${millilimit} ]; then
136        kill -9 $pid 2> /dev/null
137        cat ${logfile}
138        echo "${testname} killed after running ${max_run_time} seconds"
139        break
140      fi
141      checkBSPFaults ${logfile} >/dev/null 2>&1
142      bspFaults=$?
143      checkGenericFaults ${logfile} >/dev/null 2>&1
144      genericFaults=$?
145      if [ ${bspFaults} -ne 0 -o ${genericFaults} -ne 0 ] ; then
146        kill -9 ${pid} >/dev/null 2>&1
147        cat ${logfile}
148        echo Ran in ${milliseconds} milliseconds
149    fi
150
151  else
152    # done normally
153    cat ${logfile}
154    echo "${testname} ran in ${milliseconds} milliseconds"
155    break
156  fi
157  done
158  kill -9 $pid >/dev/null 2>&1
159}
160
161if [ "X${args}" = "X" ] ; then
162  echo no tests to run
163  exit 1
164fi
165
166## Some BSPs must generate device trees to provide to the simulator
167if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
168  bspGenerateDeviceTree
169fi
170
171## Now run the tests
172for toRun in $args
173do
174  case `basename ${toRun}` in
175    *-node*) testtype="mp"     ;;
176    *fatal*) testtype="fatal"  ;;
177    *)       testtype="single" ;;
178  esac
179
180  if [ ${interactive} = "yes" ] ; then
181    echo INTERACTIVE runtest ${toRun} ${testtype} 0
182    continue
183  fi
184
185  if [ ${limit} = "not_set" ] ; then
186    bspLimit ${toRun}
187    limit=$?
188  fi
189  if [ ${testtype} = "fatal" -a ${bspRunFatal} = "no" ] ; then
190    warn "Skipping fatal error test ${toRun}"
191    continue
192  fi
193
194  ## If the test is known to be interactive or locks up and we are
195  ## in batch mode, skip it.
196  case ${toRun} in
197    monitor* | termios* | fileio*)
198        warn "Skipping $tname; it is interactive"
199        continue
200        ;;
201    *-node2*)
202        fatal "MP tests not supported"
203        warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
204        continue;;
205    *-node1*)
206      warn "Running both nodes associated with $tname"
207      ;;
208    minimum*|spfatal|termio*)
209      warn "Skipping $tname; it locks up or takes a VERY long time to run"
210      continue
211      ;;
212   esac
213
214  test ${verbose} = "yes" && runtest ${toRun} ${testtype} ${limit}
215  runtest ${toRun} ${testtype} ${limit}
216done
217
218if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
219  bspCleanDeviceTree
220fi
221
222exit $?
223
Note: See TracBrowser for help on using the repository browser.