OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [psim/] [tools/] [runtest] - Blame information for rev 674

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
#!/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-1999.
9
#  On-Line Applications Research Corporation (OAR).
10
#
11
#  The license and distribution terms for this file may be
12
#  found in found in the file LICENSE in this distribution or at
13
#  http://www.OARcorp.com/rtems/license.html.
14
#
15
#  $Id: runtest,v 1.2 2001-09-27 12:01:02 chris Exp $
16
#
17
 
18
# progname=`basename $0`
19
progname=${0##*/}        # fast basename hack for ksh, bash
20
 
21
USAGE=\
22
"usage: $progname [ -opts ] test [ test ... ]
23
        -o options  -- specify options to be passed to simulator
24
        -v          -- verbose
25
        -d          -- generate device tree file (as 'test'.device) and exit
26
        -l logdir   -- specify log directory (default is 'logdir')
27
 
28
  Specify test as 'test' or 'test.exe'.
29
  All multiprocessing tests *must* be specified simply as 'mp01', etc.
30
"
31
 
32
# export everything
33
set -a
34
 
35
#   log an error to stderr
36
prerr()
37
{
38
    echo "$*" >&2
39
}
40
 
41
fatal() {
42
    [ "$1" ] && prerr $*
43
    prerr "$USAGE"
44
    exit 1
45
}
46
 
47
warn() {
48
    [ "$1" ] && prerr $*
49
}
50
 
51
# print args, 1 per line
52
ml_echo()
53
{
54
    for l
55
    do
56
       echo "$l"
57
    done
58
}
59
 
60
# run at normal and signalled exit
61
test_exit()
62
{
63
    exit_code=$1
64
 
65
    rm -f ${logfile}.tmp*
66
    [ "$sim_pid" ] && kill -9 $sim_pid
67
 
68
    exit $exit_code
69
}
70
 
71
#
72
# process the options
73
#
74
# defaults for getopt vars
75
#
76
# max_run_time is defaulted to 5 minutes
77
#
78
 
79
verbose=""
80
extra_options=""
81
device_and_exit=""
82
stdio_setup="yes"
83
run_to_completion="yes"
84
logdir=log
85
update_on_tick="no"
86
max_run_time=$((5 * 60))
87
using_print_buffer="yes"
88
#simulator=/usr1/rtems/work/ada/4.00/ppc_src/b-gdb/sim/ppc/run
89
simulator=powerpc-rtems-run
90
instruction_limit=1000000000
91
sizeof_ram=8388608
92
 
93
while getopts vdl:o:s: OPT
94
do
95
    case "$OPT" in
96
        v)
97
            verbose="yes";;
98
        d)
99
            device_and_exit="yes"
100
            run_to_completion="no"
101
            stdio_setup="no";;
102
        l)
103
            logdir="$OPTARG";;
104
        o)
105
            extra_options="$OPTARG";;
106
        r)
107
            sizeof_ram="$OPTARG";;
108
        s)
109
            simulator="$OPTARG";;
110
        *)
111
            fatal;;
112
    esac
113
done
114
 
115
let $((shiftcount = $OPTIND - 1))
116
shift $shiftcount
117
 
118
args=$*
119
 
120
#
121
#  Check some parameters
122
#
123
 
124
# JRS CHANGE
125
# if [ ! -x ${simulator} ] ; then
126
#    fatal "${simulator} is not executable"
127
# fi;
128
 
129
#
130
# Run the tests
131
#
132
 
133
tests="$args"
134
if [ ! "$tests" ]
135
then
136
     set -- `echo *.exe`
137
     tests="$*"
138
fi
139
 
140
[ -d $logdir ] ||
141
  mkdir $logdir || fatal "could not create log directory ($logdir)"
142
 
143
# where the tmp files go
144
trap "test_exit" 1 2 3 13 14 15
145
 
146
for tfile in $tests
147
do
148
 
149
   tname=`basename $tfile .exe`
150
   cpus="1"
151
   TEST_TYPE="single"
152
 
153
   case $tname in
154
       # size is no longer interactive.
155
       monitor*| termios*)
156
            if [ $run_to_completion = "yes" ]
157
            then
158
                 warn "Skipping $tname; it is interactive"
159
                 continue
160
            fi
161
            ;;
162
       *-node2*)
163
           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
164
           continue;;
165
       *-node1*)
166
           warn "Running both nodes associated with $tname"
167
           variant=`echo $tname | sed 's/.*-node[12]//' | sed 's/\.exe//'`
168
           tname=`echo $tname | sed 's/-node.*//'`
169
           TEST_TYPE="mp"
170
           ;;
171
       minimum*|stackchk*|spfatal*|termio*)
172
           continue
173
           ;;
174
   esac
175
 
176
   if [ $TEST_TYPE = "mp" ]
177
   then
178
       cpus="1 2"
179
 
180
       logfile1=$logdir/${tname}_1${variant}
181
       logfile2=$logdir/${tname}_2${variant}
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${variant}.exe | \
198
         sed -e 's/
//' -e '/^$/d' > ${logfile1} &
199
200
 
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${variant}.exe | \
208
         sed -e 's/
//' -e '/^$/d' > ${logfile2} &
209
210
       wait
211
 
212
   fi
213
 
214
   if [ $TEST_TYPE = "single" ]
215
 
216
     logfile=$logdir/${tname}_1
217
     infofile=$logfile.info
218
219
     rm -f ${logfile}.tmp*
220
 
221
     date=`date`
222
 
223
224
     # Generate a device file to get the work done.
225
 
226
     #
227
     #       arrange for more memory (2 Mb)
228
229
     if [ "$device_and_exit" = "yes" ]
230
 
231
          fatal "Cannot currently generate device files"
232
     fi
233
234
     # Spin off the simulator in the background
235
 
236
237
     # Don't need to make sure it won't run forever... since there is
238
 
239
240
     #powerpc-rtems-run $extra_options -c ${instruction_limit} \
241
 
242
243
     ${simulator} $extra_options -c ${instruction_limit} \
244
           -o "/#address-cells 2" \
245
 
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
 
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
 
277
278
done
279
280
echo "Tests completed at " `date`
281
test_exit 0
282
 
283
# Local Variables: ***
284
 
285
# End: ***
286
287
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.