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

4.104.114.84.95
Last change on this file since 8961188 was 8961188, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 19:49:13

new files

  • Property mode set to 100755
File size: 5.9 KB
Line 
1#!/bin/sh -p
2#
3#  $Id$
4#
5# Run rtems tests on the hppa simulator
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        -d          -- generate device tree file (as 'test'.device) 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 ${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=""
74device_and_exit=""
75stdio_setup="yes"
76run_to_completion="yes"
77logdir=log
78update_on_tick="no"
79max_run_time=$((5 * 60))
80using_print_buffer="yes"
81#simulator=/usr1/rtems/work/ada/4.00/ppc_src/b-gdb/sim/ppc/run
82simulator=powerpc-rtems-run
83instruction_limit=1000000000
84sizeof_ram=4194304
85
86while getopts vdl:o:s: OPT
87do
88    case "$OPT" in
89        v)
90            verbose="yes";;
91        d)
92            device_and_exit="yes"
93            run_to_completion="no"
94            stdio_setup="no";;
95        l)
96            logdir="$OPTARG";;
97        o)
98            extra_options="$OPTARG";;
99        r)
100            sizeof_ram="$OPTARG";;
101        s)
102            simulator="$OPTARG";;
103        *)
104            fatal;;
105    esac
106done
107
108let $((shiftcount = $OPTIND - 1))
109shift $shiftcount
110
111args=$*
112
113#
114#  Check some parameters
115#
116
117# JRS CHANGE
118# if [ ! -x ${simulator} ] ; then
119#    fatal "${simulator} is not executable"
120# fi;
121
122#
123# Run the tests
124#
125
126tests="$args"
127if [ ! "$tests" ]
128then
129     set -- `echo *.exe`
130     tests="$*"
131fi
132
133[ -d $logdir ] ||
134  mkdir $logdir || fatal "could not create log directory ($logdir)"
135
136# where the tmp files go
137trap "test_exit" 1 2 3 13 14 15
138
139for tfile in $tests
140do
141
142   tname=`basename $tfile .exe`
143   cpus="1"
144   TEST_TYPE="single"
145
146   case $tname in
147       # size is no longer interactive.
148       monitor| termios)
149            if [ $run_to_completion = "yes" ]
150            then
151                 warn "Skipping $tname; it is interactive"
152                 continue
153            fi
154            ;;
155       *-node2*)
156           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
157           continue;;
158       *-node1*)
159           warn "Running both nodes associated with $tname"
160           tname=`echo $tname | sed 's/-node.*//'`
161           TEST_TYPE="mp"
162           ;;
163       stackchk*|spfatal*|malloctest*)
164           continue
165           ;;
166   esac
167
168   if [ $TEST_TYPE = "mp" ]
169   then
170       cpus="1 2"
171
172       logfile1=$logdir/${tname}_1
173       logfile2=$logdir/${tname}_2
174       infofile1=$logfile1.info
175       infofile2=$logfile2.info
176
177       rm -f ${logfile1} ${logfile2}
178
179       date=`date`
180       echo "Starting $tname at $date"
181
182       ${simulator} $extra_options -c ${instruction_limit} \
183           -o "/#address-cells 2" \
184           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
185           -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \
186           -o "/shm@0xc0000000/key 0x1234" \
187           -o "/sem@0xc0010000/reg 0xc0010000 12" \
188           -o "/sem@0xc0010000/key 0x1234" \
189           -o "/sem@0xc0010000/value 1" ${tname}-node1.exe | \
190         sed -e 's/ //' -e '/^$/d' > ${logfile1} &
191
192       ${simulator} $extra_options -c ${instruction_limit} \
193           -o "/#address-cells 2" \
194           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
195           -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \
196           -o "/shm@0xc0000000/key 0x1234" \
197           -o "/sem@0xc0010000/reg 0xc0010000 12" \
198           -o "/sem@0xc0010000/key 0x1234" \
199           -o "/sem@0xc0010000/value -1" ${tname}-node2.exe | \
200         sed -e 's/ //' -e '/^$/d' > ${logfile2} &
201
202       wait
203
204   fi
205
206   if [ $TEST_TYPE = "single" ]
207   then
208     logfile=$logdir/${tname}_1
209     infofile=$logfile.info
210
211     rm -f ${logfile}.tmp*
212
213     date=`date`
214     echo "Starting $tname at $date"
215
216     # Generate a device file to get the work done.
217     # The device file must do the following:
218     #
219     #       arrange for more memory (2 Mb)
220
221     if [ "$device_and_exit" = "yes" ]
222     then
223          fatal "Cannot currently generate device files"
224     fi
225
226     # Spin off the simulator in the background
227     #   -c sets an instruction limit
228
229     # Don't need to make sure it won't run forever... since there is
230     # an instruction count limit
231
232     #powerpc-rtems-run $extra_options -c ${instruction_limit} \
233     #     -f ${devicefile} $tfile | sed -e 's/ //' -e '/^$/d' > ${logfile}
234
235     ${simulator} $extra_options -c ${instruction_limit} \
236           -o "/#address-cells 2" \
237           -o "/openprom/options/oea-memory-size ${sizeof_ram}" \
238           $tfile | sed -e 's/ //' -e '/^$/d' > ${logfile}
239   fi
240
241   # Create the info files
242   for cpu in $cpus
243   do
244   {
245       echo "$date"
246       echo "Test run on: `uname -n`"
247       echo "Host Information:"
248       echo `uname -a`
249       echo
250
251       #sed -e 's/ //' < ${logdir}/${tname}_${cpu}
252       cat ${logdir}/${tname}_${cpu}
253
254       if [ "$ran_too_long" = "yes" ]
255       then
256           echo "Test did NOT finish normally; killed after $max_run_time seconds"
257       fi
258
259       echo
260       date;
261   } > ${logdir}/${tname}_${cpu}.info
262   done
263
264   if [ "$cpus" = "1" ]
265   then
266        mv ${infofile} $logdir/${tname}.info
267        mv ${logfile}  $logdir/${tname}
268   fi
269
270done
271
272echo "Tests completed at " `date`
273test_exit 0
274
275# Local Variables: ***
276# mode:ksh ***
277# End: ***
278
Note: See TracBrowser for help on using the repository browser.