source: rtems-testing/sim-scripts/gdb-sim-run.in @ 66dcbe8

4.11
Last change on this file since 66dcbe8 was 66dcbe8, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 20, 2009 at 5:31:31 PM

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

  • .cvsignore, Makefile, README, gdb-sim-run.in: Add first cut at ERC32. Need to test on machine with TSIM license.
  • erc32.in: New file.
  • Property mode set to 100755
File size: 6.3 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 (default=no)
27        -g         -- generate device tree and exit (default=no)
28        -i         -- interactive (default=no time limit)
29        -s         -- force System V IPC support (default=no)
30        -l limit   -- specify time limit (default is 'BSP dependent')
31
32System V IPC and Coverage are not supported by all BSPs or simulators.
33
34When you generate a device tree and exit, remember to specify an executable.
35Otherwise, the script won't know what to generate it for.
36"
37
38#   log an error to stderr
39prerr()
40{
41    echo "$*" >&2
42}
43
44fatal() {
45    [ "$1" ] && prerr $*
46    prerr "$USAGE"
47    exit 1
48}
49
50warn() {
51    [ "$1" ] && prerr $*
52}
53
54#
55# process the options
56#
57# defaults for getopt vars
58#
59
60coverage="no"
61verbose="no"
62limit="not_set"
63interactive="no"
64use_sysv_ipc="no"
65generate_tree_and_exit="no"
66
67while getopts vgil:s OPT
68do
69 case "$OPT" in
70   v) verbose="yes";;
71   c) coverage="yes";;
72   g) generate_tree_and_exit="yes" ;;
73   i) interactive="yes";;
74   l) limit="$OPTARG";;
75   s) use_sysv_ipc="yes";;
76   *) fatal;;
77 esac
78done
79
80shiftcount=`expr $OPTIND - 1`
81shift $shiftcount
82
83if [ ${interactive} = "yes" ] ; then
84  limit=0
85fi
86
87args=$*
88
89### Set BSP defaults.  If BSP does not have default, it will override
90bspRunFatal="no"
91bspGeneratesDeviceTree="no"
92bspSupportsSystemVIPC="no"
93bspUsesGDBSimulator="yes"
94
95for v in 4.10 4.9 4.8 4.7 ""
96do
97  type @CPU_TARGET@-rtems${v}-run >/dev/null 2>&1
98  if [ $? -eq 0 ] ; then
99    defaultRUN=@CPU_TARGET@-rtems${v}-run
100    break
101  fi
102done
103
104runBSP=${defaultRUN}
105
106rtemsVersion=`echo ${progname} | sed -e 's/@BSP@-//' -e 's/-gdb//'`
107
108###################################################################
109###################################################################
110###################################################################
111##INSERT BSP SUPPORT HERE
112###################################################################
113###################################################################
114###################################################################
115
116if [ ${bspSupportsSystemVIPC} = "no" -a ${use_sysv_ipc} = "yes"  ]; then
117  echo "Simulator does not support System V IPC."
118  exit 1
119fi
120
121if [ X${runBSP} = X ] ; then
122  echo "Unable to find a way to run @CPU_TARGET@/@BSP@"
123  exit 1
124fi
125
126test ${verbose} = "yes" && echo Using ${runBSP}
127
128## These are faults any BSP may generate.  They are common to RTEMS.
129checkGenericFaults()
130{
131  logfile=$1
132
133  for pattern in  \
134     "^.*EXECUTIVE SHUTDOWN" \
135     "^\*\*\* END OF " \
136     "Suspending faulting task" \
137     "assertion failed"
138  do
139    grep "${pattern}" ${logfile} >/dev/null
140    if [ $? -eq 0 ] ; then
141      return 1
142    fi
143  done
144  return 0
145}
146
147runtest()
148{
149  testname=${1}
150  testtype=${2}
151  max_run_time=${3}
152  if [ ${max_run_time} -eq 0 ] ; then
153    #echo run ${testname} forever
154    ${runBSP} `runARGS ${testname}`
155    return
156  fi
157
158  #echo run ${testname} for maximum ${max_run_time} seconds
159  logfile=${testname}.tmp
160  ${runBSP} `runARGS ${testname}` >${logfile} 2>&1 &
161  pid=$!
162
163  # Make sure it won't run forever...
164  millilimit=`expr ${max_run_time} \* 1000`
165  milliseconds=0
166  while :
167  do
168    # sleep 10ms at a time waiting for job to finish or timer to expire
169    # if job has exited, then we exit, too.
170    usleep 10000  # ten milliseconds
171    milliseconds=`expr ${milliseconds} + 10`
172    kill -0 $pid 2> /dev/null
173    running=$?
174    if [ $running -eq 0 ] ; then
175      if [ ${milliseconds} -ge ${millilimit} ]; then
176        kill -9 $pid 2> /dev/null
177        cat ${logfile}
178        echo "${testname} killed after running ${max_run_time} seconds"
179        break
180      fi
181      if [ ! -r ${logfile} ] ; then
182        continue
183      fi
184      checkBSPFaults ${logfile} >/dev/null 2>&1
185      bspFaults=$?
186      checkGenericFaults ${logfile} >/dev/null 2>&1
187      genericFaults=$?
188      if [ ${bspFaults} -ne 0 -o ${genericFaults} -ne 0 ] ; then
189        kill -9 ${pid} >/dev/null 2>&1
190        cat ${logfile}
191        echo Ran in ${milliseconds} milliseconds
192        break
193      fi
194  else
195    # done normally
196    cat ${logfile}
197    echo "${testname} ran in ${milliseconds} milliseconds"
198    break
199  fi
200  done
201  kill -9 $pid >/dev/null 2>&1
202}
203
204if [ "X${args}" = "X" ] ; then
205  echo no tests to run
206  exit 1
207fi
208
209## Now run the tests
210for toRun in $args
211do
212  baseToRun=`basename ${toRun}`
213  case ${baseToRun} in
214    *-node*) testtype="mp"     ;;
215    *fatal*) testtype="fatal"  ;;
216    *)       testtype="single" ;;
217  esac
218  # calculate the limit in case it is used by the simulator script
219  if [ ${limit} = "not_set" ] ; then
220    bspLimit ${toRun}
221    limit=$?
222  fi
223
224  ## Some BSPs must generate device trees or scripts to provide to the simulator
225  if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
226    bspGenerateDeviceTree ${baseToRun} ${toRun} >${bspTreeFile}
227    if [ ${generate_tree_and_exit} = "yes" ] ; then
228      echo "Device tree generated and in ${bspTreeFile}"
229      exit 0
230    fi
231  fi
232
233  if [ ${interactive} = "yes" ] ; then
234    runtest ${toRun} ${testtype} 0
235    continue
236  fi
237
238  if [ ${testtype} = "fatal" -a ${bspRunFatal} = "no" ] ; then
239    warn "Skipping fatal error test ${toRun}"
240    continue
241  fi
242
243  ## If the test is known to be interactive or locks up and we are
244  ## in batch mode, skip it.
245  case ${toRun} in
246    monitor* | termios* | fileio*)
247        warn "Skipping $tname; it is interactive"
248        continue
249        ;;
250    *-node2*)
251        fatal "MP tests not supported"
252        warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
253        continue;;
254    *-node1*)
255      warn "Running both nodes associated with $tname"
256      ;;
257    minimum*|spfatal|termio*)
258      warn "Skipping $tname; it locks up or takes a VERY long time to run"
259      continue
260      ;;
261   esac
262
263  test ${verbose} = "yes" && runtest ${toRun} ${testtype} ${limit}
264  runtest ${toRun} ${testtype} ${limit}
265
266  if [ ${bspGeneratesDeviceTree} = "yes" ] ; then
267    rm -f ${bspTreeFile}
268  fi
269done
270
271exit $?
272
Note: See TracBrowser for help on using the repository browser.