source: rtems/c/src/lib/libbsp/sparc/erc32/tools/runtest.in @ 9252e55e

4.104.114.95
Last change on this file since 9252e55e was 9252e55e, checked in by Joel Sherrill <joel.sherrill@…>, on 01/29/08 at 21:37:38

2008-01-29 Joel Sherrill <joel.sherrill@…>

  • runtest.in: sp39 and sp41 lock on sis but run correctly on tsim/erc32.
  • Property mode set to 100644
File size: 6.7 KB
Line 
1#!@KSH@ -p
2#
3#  $Id$
4#
5# Run rtems tests on the SPARC simulator includeed with GDB
6# This program generates a simulator script to run each test
7# Typically the test is then run, although it can be generated
8# and left as a file using -s
9#
10
11# progname=`basename $0`
12progname=${0##*/}        # fast basename hack for ksh, bash
13
14USAGE=\
15"usage: $progname [ -opts ] test [ test ... ]
16        -o options  -- specify options to be passed to simulator
17        -v          -- verbose
18        -s          -- generate script file (as 'test'.ss) and exit
19        -l logdir   -- specify log directory (default is 'logdir')
20
21  Specify test as 'test' or 'test.exe'.
22  All multiprocessing tests *must* be specified simply as 'mp01', etc.
23"
24
25# export everything
26set -a
27
28#   log an error to stderr
29prerr()
30{
31    echo "$*" >&2
32}
33
34fatal() {
35    [ "$1" ] && prerr $*
36    prerr "$USAGE"
37    exit 1
38}
39
40warn() {
41    [ "$1" ] && prerr $*
42}
43
44# print args, 1 per line
45ml_echo()
46{
47    for l
48    do
49       echo "$l"
50    done
51}
52
53# run at normal and signalled exit
54test_exit()
55{
56    exit_code=$1
57
58    rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp*
59    [ "$sim_pid" ] && kill -9 $sim_pid
60
61    exit $exit_code
62}
63
64#
65# process the options
66#
67# defaults for getopt vars
68#
69# max_run_time is defaulted to 5 minutes
70#
71
72verbose=""
73extra_options=""
74script_and_exit=""
75stdio_setup="yes"
76run_to_completion="yes"
77logdir=log
78update_on_tick="no"
79max_run_time=$((10 * 60))
80using_print_buffer="yes"
81
82while getopts vhr12o:c:sl:t OPT
83do
84    case "$OPT" in
85        v)
86            verbose="yes";;
87        s)
88            script_and_exit="yes"
89            run_to_completion="no"
90            stdio_setup="no";;
91        l)
92            logdir="$OPTARG";;
93        o)
94            extra_options="$OPTARG";;
95        *)
96            fatal;;
97    esac
98done
99
100let $((shiftcount = $OPTIND - 1))
101shift $shiftcount
102
103args=$*
104
105#
106# Run the tests
107#
108
109tests="$args"
110if [ ! "$tests" ]
111then
112     set -- `echo *.exe`
113     tests="$*"
114fi
115
116[ -d $logdir ] ||
117  mkdir $logdir || fatal "could not create log directory ($logdir)"
118
119cpus=1
120
121# where the tmp files go
122statfile=/tmp/stats$$
123scriptfile=/tmp/script$$
124
125trap "test_exit" 1 2 3 13 14 15
126
127for tfile in $tests
128do
129
130   tname=`basename $tfile .exe`
131   TEST_TYPE="single"
132
133   case $tname in
134       capture* | monitor* | termios* | fileio* | pppd*)
135           if [ $run_to_completion = "yes" ]
136           then
137                warn "Skipping $tname; it is interactive"
138                continue
139           fi
140           ;;
141       *-node2*)
142           fatal "MP tests not supported"
143           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
144           continue;;
145      *-node1*)
146           warn "Running both nodes associated with $tname"
147           variant=`echo $tname | sed 's/.*-node[12]//' | sed 's/\.exe//'`
148           tname=`echo $tname | sed 's/-node.*//'`
149           TEST_TYPE="mp"
150           ;;
151       sp39*|sp41*)
152           warn "Skipping $tname; it does not complete long on sis"
153           continue
154           ;;
155       minimum*|stackchk*|spfatal*|termio*)
156           warn "Skipping $tname; it locks up or takes a VERY long time to run"
157           continue
158           ;;
159   esac
160
161   # Change the title bar to indicate which test we are running
162   # The simulator screen doesn't provide any indication
163
164   logfile=$logdir/$tname
165   infofile=$logfile.info
166
167   rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp*
168
169   date=`date`
170   echo "Starting $tname at $date"
171
172   # Generate a script file to get the work done.
173   # The script file must do the following:
174   #
175   #       load the program (programs if MP test)
176   #       arrange for capture of output
177   #       run the program
178   #       produce statistics
179
180   {
181       case $TEST_TYPE in
182           "mp")
183               fatal "MP tests not supported"
184               ;;
185
186           # All other tests (single-processor)
187           *)
188               echo "load $tfile"
189               echo "go 0x02000000"
190               echo ""
191               echo "perf"
192               echo "quit"
193               ;;
194       esac
195
196   } > ${scriptfile}
197
198   if [ "$script_and_exit" = "yes" ]
199   then
200        mv ${scriptfile} $tname.ss
201        warn "script left in $tname.ss"
202        test_exit 0
203   fi
204
205   # Spin off the simulator in the background
206   sparc-rtems4.9-sis $extra_options -c ${scriptfile} >${logfile}.tmp &
207   sim_pid=$!
208
209   # Make sure it won't run forever...
210   {
211       time_run=0
212       while [ $time_run -lt $max_run_time ]
213       do
214           # sleep 10s at a time waiting for job to finish or timer to expire
215           # if job has exited, then we exit, too.
216           sleep 10
217           if kill -0 $sim_pid 2>/dev/null
218           then
219                time_run=$((time_run + 10))
220           else
221                exit 0
222           fi
223       done
224
225       kill -2 $sim_pid 2>/dev/null
226       { sleep 5; kill -9 $sim_pid 2>/dev/null; } &
227   } &
228
229   wait $sim_pid
230   status=$?
231   if [ $status -ne 0 ]
232   then
233       ran_too_long="yes"
234   else
235       ran_too_long="no"
236   fi
237
238   sim_pid=""
239
240   # fix up the printf output from the test
241   case $TEST_TYPE in
242       mp)
243           fatal "MP not supported"
244           ;;
245       *)
246           output_it=1
247           grep -v "Memory exception " ${logfile}.tmp | \
248           sed -e '1,9d' \
249               -e 's/ //' -e '/^$/d' | \
250             while read line
251              do
252                if [ $output_it -eq 1 ] ; then
253                   if [ "$line" = "sis> perf" ] ; then
254                     output_it=0
255                   elif [ "$line" = "sis> quit" ] ; then
256                     output_it=0
257                   elif [ "$line" = "sis>" ] ; then
258                     output_it=0
259                   else
260                     echo "$line"
261                   fi   
262                 fi 
263               done > ${logfile}_1
264           ;;
265   esac
266
267   # Create the info files
268   for cpu in $cpus
269   do
270   {
271       echo "$date"
272       echo "Test run on: `uname -n`    ( `uname -a` )"
273
274       output_it=0
275       grep -v "Memory exception " ${logfile}.tmp | \
276       sed -e 's/ //' | \
277         while read line
278         do
279           if [ $output_it -eq 1 ] ; then
280              if [ "$line" = "sis> quit" ] ; then
281                output_it=0
282              else
283                echo "$line"
284              fi
285            else
286              if [ "$line" = "sis> perf" ] ; then
287                output_it=1
288              fi
289            fi
290          done
291
292
293       if [ "$ran_too_long" = "yes" ]
294       then
295           echo "Test did NOT finish normally; killed after $max_run_time seconds"
296       fi
297
298       echo
299       date;
300   } > ${infofile}_$cpu
301   done
302
303   rm -f ${logfile}.tmp*
304
305   if [ "$cpus" = "1" ]
306   then
307        mv ${infofile}_1 ${infofile}
308        mv ${logfile}_1  ${logfile}
309   fi
310
311done
312
313test_exit 0
314
315# Local Variables: ***
316# mode:ksh ***
317# End: ***
318
Note: See TracBrowser for help on using the repository browser.