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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [sparc/] [erc32/] [tools/] [runtest.in] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
#!@KSH@ -p
2
#
3
#  $Id: runtest.in,v 1.2 2001-09-27 12:01:14 chris Exp $
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`
12
progname=${0##*/}        # fast basename hack for ksh, bash
13
 
14
USAGE=\
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
26
set -a
27
 
28
#   log an error to stderr
29
prerr()
30
{
31
    echo "$*" >&2
32
}
33
 
34
fatal() {
35
    [ "$1" ] && prerr $*
36
    prerr "$USAGE"
37
    exit 1
38
}
39
 
40
warn() {
41
    [ "$1" ] && prerr $*
42
}
43
 
44
# print args, 1 per line
45
ml_echo()
46
{
47
    for l
48
    do
49
       echo "$l"
50
    done
51
}
52
 
53
# run at normal and signalled exit
54
test_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
 
72
verbose=""
73
extra_options=""
74
script_and_exit=""
75
stdio_setup="yes"
76
run_to_completion="yes"
77
logdir=log
78
update_on_tick="no"
79
max_run_time=$((5 * 60))
80
using_print_buffer="yes"
81
 
82
while getopts vhr12o:c:sl:t OPT
83
do
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
98
done
99
 
100
let $((shiftcount = $OPTIND - 1))
101
shift $shiftcount
102
 
103
args=$*
104
 
105
#
106
# Run the tests
107
#
108
 
109
tests="$args"
110
if [ ! "$tests" ]
111
then
112
     set -- `echo *.exe`
113
     tests="$*"
114
fi
115
 
116
[ -d $logdir ] ||
117
  mkdir $logdir || fatal "could not create log directory ($logdir)"
118
 
119
cpus=1
120
 
121
# where the tmp files go
122
statfile=/tmp/stats$$
123
scriptfile=/tmp/script$$
124
 
125
trap "test_exit" 1 2 3 13 14 15
126
 
127
for tfile in $tests
128
do
129
 
130
   tname=`basename $tfile .exe`
131
   TEST_TYPE="single"
132
 
133
   case $tname in
134
       monitor)
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
       minimum*|stackchk*|spfatal*|termio*)
152
           warn "Skipping $tname; it locks up or takes a VERY long time to run"
153
           continue
154
           ;;
155
   esac
156
 
157
   # Change the title bar to indicate which test we are running
158
   # The simulator screen doesn't provide any indication
159
 
160
   logfile=$logdir/$tname
161
   infofile=$logfile.info
162
 
163
   rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp*
164
 
165
   date=`date`
166
   echo "Starting $tname at $date"
167
 
168
   # Generate a script file to get the work done.
169
   # The script file must do the following:
170
   #
171
   #       load the program (programs if MP test)
172
   #       arrange for capture of output
173
   #       run the program
174
   #       produce statistics
175
 
176
   {
177
       case $TEST_TYPE in
178
           "mp")
179
               fatal "MP tests not supported"
180
               ;;
181
 
182
           # All other tests (single-processor)
183
           *)
184
               echo "load $tfile"
185
               echo "go 0x02000000"
186
               echo ""
187
               echo "perf"
188
               echo "quit"
189
               ;;
190
       esac
191
 
192
   } > ${scriptfile}
193
 
194
   if [ "$script_and_exit" = "yes" ]
195
   then
196
        mv ${scriptfile} $tname.ss
197
        warn "script left in $tname.ss"
198
        test_exit 0
199
   fi
200
 
201
   # Spin off the simulator in the background
202
   sparc-rtems-sis $extra_options -c ${scriptfile} >${logfile}.tmp &
203
   sim_pid=$!
204
 
205
   # Make sure it won't run forever...
206
   {
207
       time_run=0
208
       while [ $time_run -lt $max_run_time ]
209
       do
210
           # sleep 10s at a time waiting for job to finish or timer to expire
211
           # if job has exited, then we exit, too.
212
           sleep 10
213
           if kill -0 $sim_pid 2>/dev/null
214
           then
215
                time_run=$((time_run + 10))
216
           else
217
                exit 0
218
           fi
219
       done
220
 
221
       kill -2 $sim_pid 2>/dev/null
222
       { sleep 5; kill -9 $sim_pid 2>/dev/null; } &
223
   } &
224
 
225
   wait $sim_pid
226
   status=$?
227
   if [ $status -ne 0 ]
228
   then
229
       ran_too_long="yes"
230
   else
231
       ran_too_long="no"
232
   fi
233
 
234
   sim_pid=""
235
 
236
   # fix up the printf output from the test
237
   case $TEST_TYPE in
238
       mp)
239
           fatal "MP not supported"
240
           ;;
241
       *)
242
           output_it=1
243
           sed -e '1,9d' \
244
               -e 's/
//' -e '/^$/d' < ${logfile}.tmp |
245
             while read line
246
              do
247
                if [ $output_it -eq 1 ] ; then
248
                   if [ "$line" = "sis> perf" ] ; then
249
                     output_it=0
250
                   elif [ "$line" = "sis> quit" ] ; then
251
                     output_it=0
252
                   elif [ "$line" = "sis>" ] ; then
253
                     output_it=0
254
                   else
255
                     echo "$line"
256
                   fi
257
                 fi
258
               done > ${logfile}_1
259
           ;;
260
   esac
261
262
 
263
   for cpu in $cpus
264
   do
265
   {
266
       echo "$date"
267
       echo "Test run on: `uname -n`    ( `uname -a` )"
268
269
 
270
       sed -e 's/
//' < ${logfile}.tmp |
271
         while read line
272
         do
273
           if [ $output_it -eq 1 ] ; then
274
              if [ "$line" = "sis> quit" ] ; then
275
                output_it=0
276
              else
277
                echo "$line"
278
              fi
279
            else
280
              if [ "$line" = "sis> perf" ] ; then
281
                output_it=1
282
              fi
283
            fi
284
          done
285
286
287
 
288
 
289
           echo "Test did NOT finish normally; killed after $max_run_time seconds"
290
       fi
291
292
       echo
293
 
294
   } > ${infofile}_$cpu
295
   done
296
297
   rm -f ${logfile}.tmp*
298
 
299
   if [ "$cpus" = "1" ]
300
 
301
        mv ${infofile}_1 ${infofile}
302
        mv ${logfile}_1  ${logfile}
303
   fi
304
305
done
306
 
307
test_exit 0
308
 
309
# Local Variables: ***
310
 
311
# End: ***
312
313

powered by: WebSVN 2.1.0

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