source: rtems/c/src/lib/libbsp/powerpc/psim/tools/runtest @ ba05e31

4.104.114.84.95
Last change on this file since ba05e31 was ba05e31, checked in by Joel Sherrill <joel.sherrill@…>, on 04/30/98 at 11:41:57

Added wildcard to switch for monitor and termios.

  • Property mode set to 100755
File size: 6.2 KB
Line 
1#!/bin/sh -p
2#
3# Run rtems tests on the powerpc simulator
4# This program generates a simulator script to run each test
5# Typically the test is then run, although it can be generated
6# and left as a file using -s
7#
8#  COPYRIGHT (c) 1989-1998.
9#  On-Line Applications Research Corporation (OAR).
10#  Copyright assigned to U.S. Government, 1994.
11#
12#  The license and distribution terms for this file may be
13#  found in found in the file LICENSE in this distribution or at
14#  http://www.OARcorp.com/rtems/license.html.
15#
16#  $Id$
17#
18
19# progname=`basename $0`
20progname=${0##*/}        # fast basename hack for ksh, bash
21
22USAGE=\
23"usage: $progname [ -opts ] test [ test ... ]
24        -o options  -- specify options to be passed to simulator
25        -v          -- verbose
26        -d          -- generate device tree file (as 'test'.device) and exit
27        -l logdir   -- specify log directory (default is 'logdir')
28
29  Specify test as 'test' or 'test.exe'.
30  All multiprocessing tests *must* be specified simply as 'mp01', etc.
31"
32
33# export everything
34set -a
35
36#   log an error to stderr
37prerr()
38{
39    echo "$*" >&2
40}
41
42fatal() {
43    [ "$1" ] && prerr $*
44    prerr "$USAGE"
45    exit 1
46}
47
48warn() {
49    [ "$1" ] && prerr $*
50}
51
52# print args, 1 per line
53ml_echo()
54{
55    for l
56    do
57       echo "$l"
58    done
59}
60
61# run at normal and signalled exit
62test_exit()
63{
64    exit_code=$1
65
66    rm -f ${logfile}.tmp*
67    [ "$sim_pid" ] && kill -9 $sim_pid
68
69    exit $exit_code
70}
71
72#
73# process the options
74#
75# defaults for getopt vars
76#
77# max_run_time is defaulted to 5 minutes
78#
79
80verbose=""
81extra_options=""
82device_and_exit=""
83stdio_setup="yes"
84run_to_completion="yes"
85logdir=log
86update_on_tick="no"
87max_run_time=$((5 * 60))
88using_print_buffer="yes"
89#simulator=/usr1/rtems/work/ada/4.00/ppc_src/b-gdb/sim/ppc/run
90simulator=powerpc-rtems-run
91instruction_limit=1000000000
92sizeof_ram=4194304
93
94while getopts vdl:o:s: OPT
95do
96    case "$OPT" in
97        v)
98            verbose="yes";;
99        d)
100            device_and_exit="yes"
101            run_to_completion="no"
102            stdio_setup="no";;
103        l)
104            logdir="$OPTARG";;
105        o)
106            extra_options="$OPTARG";;
107        r)
108            sizeof_ram="$OPTARG";;
109        s)
110            simulator="$OPTARG";;
111        *)
112            fatal;;
113    esac
114done
115
116let $((shiftcount = $OPTIND - 1))
117shift $shiftcount
118
119args=$*
120
121#
122#  Check some parameters
123#
124
125# JRS CHANGE
126# if [ ! -x ${simulator} ] ; then
127#    fatal "${simulator} is not executable"
128# fi;
129
130#
131# Run the tests
132#
133
134tests="$args"
135if [ ! "$tests" ]
136then
137     set -- `echo *.exe`
138     tests="$*"
139fi
140
141[ -d $logdir ] ||
142  mkdir $logdir || fatal "could not create log directory ($logdir)"
143
144# where the tmp files go
145trap "test_exit" 1 2 3 13 14 15
146
147for tfile in $tests
148do
149
150   tname=`basename $tfile .exe`
151   cpus="1"
152   TEST_TYPE="single"
153
154   case $tname in
155       # size is no longer interactive.
156       monitor*| termios*)
157            if [ $run_to_completion = "yes" ]
158            then
159                 warn "Skipping $tname; it is interactive"
160                 continue
161            fi
162            ;;
163       *-node2*)
164           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
165           continue;;
166       *-node1*)
167           warn "Running both nodes associated with $tname"
168           tname=`echo $tname | sed 's/-node.*//'`
169           TEST_TYPE="mp"
170           ;;
171       stackchk*|spfatal*|malloctest*)
172           continue
173           ;;
174   esac
175
176   if [ $TEST_TYPE = "mp" ]
177   then
178       cpus="1 2"
179
180       logfile1=$logdir/${tname}_1
181       logfile2=$logdir/${tname}_2
182       infofile1=$logfile1.info
183       infofile2=$logfile2.info
184
185       rm -f ${logfile1} ${logfile2}
186
187       date=`date`
188       echo "Starting $tname at $date"
189
190       ${simulator} $extra_options -c ${instruction_limit} \
191           -o "/#address-cells 2" \
192           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
193           -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \
194           -o "/shm@0xc0000000/key 0x1234" \
195           -o "/sem@0xc0010000/reg 0xc0010000 12" \
196           -o "/sem@0xc0010000/key 0x1234" \
197           -o "/sem@0xc0010000/value 1" ${tname}-node1.exe | \
198         sed -e 's/ //' -e '/^$/d' > ${logfile1} &
199
200       ${simulator} $extra_options -c ${instruction_limit} \
201           -o "/#address-cells 2" \
202           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
203           -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \
204           -o "/shm@0xc0000000/key 0x1234" \
205           -o "/sem@0xc0010000/reg 0xc0010000 12" \
206           -o "/sem@0xc0010000/key 0x1234" \
207           -o "/sem@0xc0010000/value -1" ${tname}-node2.exe | \
208         sed -e 's/ //' -e '/^$/d' > ${logfile2} &
209
210       wait
211
212   fi
213
214   if [ $TEST_TYPE = "single" ]
215   then
216     logfile=$logdir/${tname}_1
217     infofile=$logfile.info
218
219     rm -f ${logfile}.tmp*
220
221     date=`date`
222     echo "Starting $tname at $date"
223
224     # Generate a device file to get the work done.
225     # The device file must do the following:
226     #
227     #       arrange for more memory (2 Mb)
228
229     if [ "$device_and_exit" = "yes" ]
230     then
231          fatal "Cannot currently generate device files"
232     fi
233
234     # Spin off the simulator in the background
235     #   -c sets an instruction limit
236
237     # Don't need to make sure it won't run forever... since there is
238     # an instruction count limit
239
240     #powerpc-rtems-run $extra_options -c ${instruction_limit} \
241     #     -f ${devicefile} $tfile | sed -e 's/ //' -e '/^$/d' > ${logfile}
242
243     ${simulator} $extra_options -c ${instruction_limit} \
244           -o "/#address-cells 2" \
245           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
246           $tfile | sed -e 's/ //' -e '/^$/d' > ${logfile}
247   fi
248
249   # Create the info files
250   for cpu in $cpus
251   do
252   {
253       echo "$date"
254       echo "Test run on: `uname -n`"
255       echo "Host Information:"
256       echo `uname -a`
257       echo
258
259       #sed -e 's/ //' < ${logdir}/${tname}_${cpu}
260       cat ${logdir}/${tname}_${cpu}
261
262       if [ "$ran_too_long" = "yes" ]
263       then
264           echo "Test did NOT finish normally; killed after $max_run_time seconds"
265       fi
266
267       echo
268       date;
269   } > ${logdir}/${tname}_${cpu}.info
270   done
271
272   if [ "$cpus" = "1" ]
273   then
274        mv ${infofile} $logdir/${tname}.info
275        mv ${logfile}  $logdir/${tname}
276   fi
277
278done
279
280echo "Tests completed at " `date`
281test_exit 0
282
283# Local Variables: ***
284# mode:ksh ***
285# End: ***
286
Note: See TracBrowser for help on using the repository browser.