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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [c4x/] [c4xsim/] [tools/] [runtest.in] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
#!@KSH@ -p
2
#
3
#  runtest.in,v 1.1 2000/02/22 18:39:52 joel Exp
4
#
5
# Run rtems tests on the c4x simulator built into 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`
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=$((6 * 60))  # is 5 on other simulators.
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
           fatal "MP tests not supported"
147
           warn "Running both nodes associated with $tname"
148
           tname=`echo $tname | sed 's/-node.*//'`
149
           TEST_TYPE="mp"
150
           ;;
151
       stackchk*|spfatal*|malloctest*|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 "target sim -3"
185
               echo "sim m r 0"
186
               echo "sim m w 0"
187
               echo "load"
188
               echo ""
189
               echo "printf \"START_OF_TEST\\n\""
190
               echo "run"
191
               echo "printf \"END_OF_TEST\\n\""
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
   c4x-rtems-gdb $extra_options -n \
207
        --command ${scriptfile} ${tfile} >${logfile}.tmp 2>&1 &
208
   sim_pid=$!
209
 
210
   # Make sure it won't run forever...
211
   {
212
       time_run=0
213
       while [ $time_run -lt $max_run_time ]
214
       do
215
           # sleep 10s at a time waiting for job to finish or timer to expire
216
           # if job has exited, then we exit, too.
217
           sleep 10
218
           if kill -0 $sim_pid 2>/dev/null
219
           then
220
                time_run=$((time_run + 10))
221
           else
222
                exit 0
223
           fi
224
       done
225
 
226
       kill -2 $sim_pid 2>/dev/null
227
       { sleep 5; kill -9 $sim_pid 2>/dev/null; } &
228
   } &
229
 
230
   wait $sim_pid
231
   status=$?
232
   if [ $status -ne 0 ]
233
   then
234
       ran_too_long="yes"
235
   else
236
       ran_too_long="no"
237
   fi
238
 
239
   sim_pid=""
240
 
241
   # fix up the printf output from the test
242
   case $TEST_TYPE in
243
       mp)
244
           fatal "MP not supported"
245
           ;;
246
       *)
247
           output_it=0
248
           clean_exit=0
249
           sed -e '1,9d' \
250
               -e 's/
//' -e '/^$/d' < ${logfile}.tmp |
251
             while read line
252
              do
253
                if [ $output_it -eq 1 ] ; then
254
                   case $line in
255
                       END_OF_TEST*)
256
                       output_it=0
257
                       ;;
258
                      *simio.c:86*)
259
                        output_it=0
260
                        clean_exit=1
261
                        ;;
262
                      *)
263
                        echo "$line"
264
                        ;;
265
                     esac
266
                 else
267
                   if [ "$line" = "START_OF_TEST" ] ; then
268
                     output_it=1
269
                   fi
270
                 fi
271
               done > ${logfile}_1
272
               if [ ${clean_exit} -eq 0 ] ; then
273
                 mv ${logfile}_1 ${logfile}_1.XXX
274
                 sed -e '/^Program received signal SIGTRAP/d' \
275
                    <${logfile}_1.XXX >${logfile}_1
276
                 rm -f ${logfile}_1.XXX
277
               fi
278
           ;;
279
   esac
280
281
 
282
   for cpu in $cpus
283
   do
284
   {
285
       echo "$date"
286
       echo "Test run on: `uname -n`    ( `uname -a` )"
287
288
 
289
       sed -e 's/
//' < ${logfile}.tmp |
290
         while read line
291
         do
292
           if [ $output_it -eq 0 ] ; then
293
              if [ "$line" = "END_OF_TEST" ] ; then
294
                output_it=1
295
              fi
296
            else
297
              if [ "$line" = "START_OF_TEST" ] ; then
298
                output_it=0
299
              else
300
                echo "$line"
301
              fi
302
            fi
303
          done
304
305
306
 
307
 
308
           echo "Test did NOT finish normally; killed after $max_run_time seconds"
309
       fi
310
311
       echo
312
 
313
   } > ${infofile}_$cpu
314
   done
315
316
   rm -f ${logfile}.tmp*
317
 
318
   if [ "$cpus" = "1" ]
319
 
320
        mv ${infofile}_1 ${infofile}
321
        mv ${logfile}_1  ${logfile}
322
   fi
323
324
done
325
 
326
test_exit 0
327
 
328
# Local Variables: ***
329
 
330
# End: ***
331
332

powered by: WebSVN 2.1.0

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