source: rtems/c/src/lib/libbsp/sh/simsh4/tools/runtest.in @ 3c769d9

4.104.114.95
Last change on this file since 3c769d9 was 3c769d9, checked in by Joel Sherrill <joel.sherrill@…>, on 03/11/08 at 20:17:23

2008-03-11 Joel Sherrill <joel.sherrill@…>

  • runtest.in: Skip all fatal error tests.
  • Property mode set to 100644
File size: 4.8 KB
Line 
1#!@KSH@ -p
2#
3# Run rtems tests on the Motorola MCF5206eLITE Coldfire Evaluation board
4# using gdb configured with P&E Micro Background Debug Mode debugging
5# interface.
6#
7# This program generates a gdb script to run each test, intercept
8# serial port output and put log into output file.
9#
10# Author: Victor V. Vengerov <vvv@oktet.ru>
11# Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
12#
13# Partially based on runtest script for powerpc psim.
14#
15#  COPYRIGHT (c) 1989-1999.
16#  On-Line Applications Research Corporation (OAR).
17#
18#  The license and distribution terms for this file may be
19#  found in found in the file LICENSE in this distribution or at
20#  http://www.rtems.com/license/LICENSE.
21#
22#  @(#) $Id$
23#
24
25# progname=`basename $0`
26progname=${0##*/}        # fast basename hack for ksh, bash
27
28USAGE=\
29"usage: $progname [ -opts ] test [ test ... ]
30        -r runname   -- specify name of run program to be used
31        -v           -- verbose output
32        -d           -- don't remove temporary files (for debugging only)
33        -l logdir    -- specify log directory (default is 'logdir')
34
35  Specify test as 'test' or 'test.exe'.
36  All multiprocessing tests *must* be specified simply as 'mp01', etc.
37"
38
39# export everything
40set -a
41
42#   log an error to stderr
43prerr()
44{
45    echo "$*" >&2
46}
47
48fatal() {
49    [ "$1" ] && prerr $*
50    prerr "$USAGE"
51    exit 1
52}
53
54warn() {
55    [ "$1" ] && prerr $*
56}
57
58# run at normal and signalled exit
59test_exit()
60{
61    exit_code=$1
62
63    rm -f ${logfile}.tmp*
64    [ "$run_pid" ] && kill -9 $run_pid
65
66    exit $exit_code
67}
68
69#
70# process the options
71#
72# defaults for getopt vars
73#
74# max_run_time is defaulted to 5 minutes
75#
76
77verbose=""
78runprog=sh-rtemself-run
79logdir=log
80max_run_time=$((10 * 60))
81#sizeof_ram=$((1 * 1024 * 1024))
82debugging="no"
83#console_mode=0
84
85while getopts vdips:r:b:l: OPT
86do
87    case "$OPT" in
88        v)
89            verbose="yes";;
90        d)
91            debugging="yes";;
92        l)
93            logdir="$OPTARG";;
94        r)
95            runprog="$OPTARG";;
96#        p)
97#            console_mode=1;;
98#        i)
99#            console_mode=2;;
100        *)
101            fatal;;
102    esac
103done
104
105let $((shiftcount = $OPTIND - 1))
106shift $shiftcount
107
108args=$*
109
110#
111# Run the tests
112#
113
114tests="$args"
115if [ ! "$tests" ]
116then
117     set -- `echo *.exe`
118     tests="$*"
119fi
120
121[ -d $logdir ] ||
122  mkdir $logdir || fatal "could not create log directory ($logdir)"
123
124# where the tmp files go
125trap "test_exit" 1 2 3 13 14 15
126
127for tfile in $tests
128do
129
130   tname=`basename $tfile .exe`
131   cpus="1"
132   TEST_TYPE="single"
133
134   case "$tname" in
135       # size is no longer interactive.
136       capture* | monitor* | termios* | fileio* | pppd*)
137            warn "Skipping $tname; it is interactive"
138            continue
139            ;;
140       *-node2*)
141           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
142           continue
143           ;;
144       *-node1*)
145           warn "Running both nodes associated with $tname"
146           tname=`echo $tname | sed 's/-node.*//'`
147           TEST_TYPE="mp"
148           ;;
149       minimum*|stackchk*|*fatal*|termio*)
150           continue
151           ;;
152   esac
153
154   if [ "$TEST_TYPE" = "mp" ] ; then
155       fatal "MP tests not supported for this board"
156   fi
157
158   if [ $TEST_TYPE = "single" ] ; then
159     logfile=$logdir/${tname}
160     infofile=${logfile}.info
161#     scriptfile=${logfile}.ss
162#     runlogfile=${logfile}.run
163
164     rm -f ${logfile}.tmp*
165
166     date=`date`
167     echo "Starting $tname at $date"
168
169     ${runprog} "${tfile}" > "${logfile}"  2>&1 &
170     run_pid=$!
171     {
172         time_run=0
173         while [ $time_run -lt $max_run_time ] ; do
174             sleep 10s
175             if kill -0 $run_pid 2> /dev/null ; then
176                 time_run=$((time_run+10)) ;
177             else
178                 exit 0
179             fi
180         done
181         kill -2 $run_pid 2> /dev/null
182         {
183             sleep 5s ;
184             if kill -0 $run_pid 2> /dev/null ; then
185                 kill -9 $run_pid 2> /dev/null ;
186             fi
187         } &
188     } &
189     wait $run_pid
190     run_status=$?
191     if [ $run_status -ge 128 ] ; then
192         ran_too_long="yes" ;
193     else
194         ran_too_long="no"
195     fi
196     if [ $run_status -ne 0 ] ; then
197         test_failed="yes" ;
198     else
199         test_failed="no"
200     fi
201     run_pid=""
202   fi
203
204   # Create the info files
205   {
206       echo "$date"
207       echo "Test run on: `uname -n`"
208       echo "Host Information:"
209       echo `uname -a`
210       echo
211       echo "run:         `type -path ${runprog}`"
212
213       cat ${logfile}
214
215       if [ "$test_failed" = "yes" ] ; then
216           echo -e "\\n\\nTest did not finish normally"
217           if [ "$ran_too_long" = "yes" ] ; then
218               echo "Test killed after $max_run_time seconds"
219           fi
220       fi
221
222       echo
223       date;
224   } > ${infofile}
225#   if [ "${debugging}" = "no" ] ; then
226#       rm -f ${runlogfile}
227#   fi
228done
229
230echo "Tests completed at " `date`
231test_exit 0
Note: See TracBrowser for help on using the repository browser.