source: rtems/bsps/m68k/mcf5206elite/runtest

Last change on this file was 419d1e9, checked in by Sebastian Huber <sebastian.huber@…>, on 04/25/18 at 14:06:34

bsp/mcf5206elite: Do not install runtest script

Provide the runtest script only as a part of the sources. This
simplifies the build system.

Test support should be included in the RTEMS Tester.

  • Property mode set to 100644
File size: 8.3 KB
Line 
1#! /bin/sh -p
2#
3# Run rtems tests on the Motorola MCF5206eLITE Coldfire Evaluation board
4# using gdb configured with P&E Micro Background Debug Mode debugging
5# interface.
6#
7# This program generates a gdb script to run each test, intercept
8# serial port output and put log into output file.
9#
10# Author: Victor V. Vengerov <vvv@oktet.ru>
11# Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
12#
13# Partially based on runtest script for powerpc psim.
14#
15#  COPYRIGHT (c) 1989-1999.
16#  On-Line Applications Research Corporation (OAR).
17#
18#  The license and distribution terms for this file may be
19#  found in the file LICENSE in this distribution or at
20#  http://www.rtems.org/license/LICENSE.
21#
22
23# progname=`basename $0`
24progname=${0##*/}        # fast basename hack for ksh, bash
25
26USAGE=\
27"usage: $progname [ -opts ] test [ test ... ]
28        -s ttydevice -- specify serial device to be used to capture test
29                        output
30        -r baud      -- set serial port baud rate (19200 by default)
31        -b bdmdevice -- specify BDM device to be used to control the target
32        -g gdbname   -- specify name of gdb program to be used
33        -v           -- verbose output
34        -d           -- don't remove temporary files (for debugging only)
35        -i           -- use interrupt driven console I/O when test is running
36                        (many tests failed when interrupt driven console
37                        input/output is used due undetermenistic tests
38                        behaviour)
39        -p           -- use termios poll console I/O
40        -l logdir    -- specify log directory (default is 'logdir')
41
42  Specify test as 'test' or 'test.exe'.
43  All multiprocessing tests *must* be specified simply as 'mp01', etc.
44"
45
46# export everything
47set -a
48
49#   log an error to stderr
50prerr()
51{
52    echo "$*" >&2
53}
54
55fatal() {
56    [ "$1" ] && prerr $*
57    prerr "$USAGE"
58    exit 1
59}
60
61warn() {
62    [ "$1" ] && prerr $*
63}
64
65# run at normal and signalled exit
66test_exit()
67{
68    exit_code=$1
69
70    rm -f ${logfile}.tmp*
71    [ "$gdb_pid" ] && kill -9 $gdb_pid
72    [ "$serial_pid" ] && kill -9 $serial_pid
73
74    exit $exit_code
75}
76
77#
78# process the options
79#
80# defaults for getopt vars
81#
82# max_run_time is defaulted to 5 minutes
83#
84
85verbose=""
86serial_device=/dev/ttyS0
87bdm_device=/dev/bdmcf0
88gdbprog=true
89for i in rtems bdm-rtems bdm bdm-elf bdm-coff ; do
90    if m68k-$i-gdb --version > /dev/null 2>&1 ; then
91        gdbprog=m68k-$i-gdb ;
92        break ;
93    fi
94done
95logdir=log
96max_run_time=$((5 * 60))
97sizeof_ram=$((1 * 1024 * 1024))
98debugging="no"
99baudrate="19200"
100console_mode=0
101
102while getopts vdips:r:b:l: OPT
103do
104    case "$OPT" in
105        v)
106            verbose="yes";;
107        d)
108            debugging="yes";;
109        s)
110            serial_device="$OPTARG";;
111        r)
112            baudrate="$OPTARG";;
113        b)
114            bdm_device="$OPTARG";;
115        l)
116            logdir="$OPTARG";;
117        s)
118            gdbprog="$OPTARG";;
119        p)
120            console_mode=1;;
121        i)
122            console_mode=2;;
123        *)
124            fatal;;
125    esac
126done
127
128let $((shiftcount = $OPTIND - 1))
129shift $shiftcount
130
131args=$*
132
133#
134# Run the tests
135#
136
137tests="$args"
138if [ ! "$tests" ]
139then
140     set -- `echo *.exe`
141     tests="$*"
142fi
143
144[ -d $logdir ] ||
145  mkdir $logdir || fatal "could not create log directory ($logdir)"
146
147# where the tmp files go
148trap "test_exit" 1 2 3 13 14 15
149
150for tfile in $tests
151do
152
153   tname=`basename $tfile .exe`
154   cpus="1"
155   TEST_TYPE="single"
156
157   case "$tname" in
158       # size is no longer interactive.
159       capture* | monitor* | termios* | fileio* | pppd*)
160            warn "Skipping $tname; it is interactive"
161            continue
162            ;;
163       *-node2*)
164           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
165           continue
166           ;;
167       *-node1*)
168           warn "Running both nodes associated with $tname"
169           tname=`echo $tname | sed 's/-node.*//'`
170           TEST_TYPE="mp"
171           ;;
172       minimum*|stackchk*|*fatal*|malloctest*)
173           continue
174           ;;
175   esac
176
177   if [ "$TEST_TYPE" = "mp" ] ; then
178       fatal "MP tests not supported for this board"
179   fi
180
181   if [ $TEST_TYPE = "single" ] ; then
182     logfile=$logdir/${tname}
183     infofile=${logfile}.info
184     scriptfile=${logfile}.ss
185     gdblogfile=${logfile}.gdb
186
187     rm -f ${logfile}.tmp*
188
189     date=`date`
190     echo "Starting $tname at $date"
191
192     # Set serial port parameters
193     if ! stty -F ${serial_device} raw cs8 -cstopb cread crtscts \
194                    ispeed ${baudrate} ospeed ${baudrate} \
195                    > /dev/null 2> /dev/null ; then
196         fatal "Serial port couldn't be configured"
197     fi
198
199     # Flush serial port
200     cat ${serial_device} > /dev/null &
201     serial_pid=$!
202     sleep 1s
203     kill ${serial_pid}
204
205     # Capture serial port
206     cat ${serial_device} > $logfile &
207     serial_pid=$!
208
209     cat > "${scriptfile}" <<EOF
210target bdm $bdm_device
211set \$mbar  = 0x10000001
212set \$csar0 = \$mbar - 1 + 0x064
213set \$csmr0 = \$mbar - 1 + 0x068
214set \$cscr0 = \$mbar - 1 + 0x06E
215set \$csar1 = \$mbar - 1 + 0x070
216set \$csmr1 = \$mbar - 1 + 0x074
217set \$cscr1 = \$mbar - 1 + 0x07A
218set \$csar2 = \$mbar - 1 + 0x07C
219set \$csmr2 = \$mbar - 1 + 0x080
220set \$cscr2 = \$mbar - 1 + 0x086
221set \$csar3 = \$mbar - 1 + 0x088
222set \$csmr3 = \$mbar - 1 + 0x08C
223set \$cscr3 = \$mbar - 1 + 0x092
224set \$csar4 = \$mbar - 1 + 0x094
225set \$csmr4 = \$mbar - 1 + 0x098
226set \$cscr4 = \$mbar - 1 + 0x09E
227set \$csar5 = \$mbar - 1 + 0x0A0
228set \$csmr5 = \$mbar - 1 + 0x0A4
229set \$cscr5 = \$mbar - 1 + 0x0AA
230set \$csar6 = \$mbar - 1 + 0x0AC
231set \$csmr6 = \$mbar - 1 + 0x0B0
232set \$cscr6 = \$mbar - 1 + 0x0B6
233set \$csar7 = \$mbar - 1 + 0x0B8
234set \$csmr7 = \$mbar - 1 + 0x0BC
235set \$cscr7 = \$mbar - 1 + 0x0C2
236
237set *((short*) \$csar0) = 0xffe0
238set *((int*)   \$csmr0) = 0x000f0000
239set *((short*) \$cscr0) = 0x1da3
240set *((short*) \$csar1) = 0x5000
241set *((int*)   \$csmr1) = 0x00000000
242set *((short*) \$cscr1) = 0x3d43
243set *((short*) \$csar2) = 0x3000
244set *((int*)   \$csmr2) = 0x000f0000
245set *((short*) \$cscr2) = 0x1903
246set *((short*) \$csar3) = 0x4000
247set *((int*)   \$csmr3) = 0x000f0000
248set *((short*) \$cscr3) = 0x0083
249#
250load
251# Many tests not working properly when interrupt driven console I/O is used.
252set console_mode=$console_mode
253set \$pc=start
254set \$sp=0x20001ffc
255#
256break bsp_cleanup
257commands
258shell kill $serial_pid
259quit
260end
261#
262break _stop
263commands
264shell kill $serial_pid
265quit 1
266end
267#
268continue
269quit 2
270EOF
271     ${gdbprog} -x "${scriptfile}" "${tfile}" > "${gdblogfile}"  2>&1 &
272     gdb_pid=$!
273     {
274         time_run=0
275         while [ $time_run -lt $max_run_time ] ; do
276             sleep 10s
277             if kill -0 $gdb_pid 2> /dev/null ; then
278                 time_run=$((time_run+10)) ;
279             else
280                 exit 0
281             fi
282         done
283         kill -2 $serial_pid 2> /dev/null
284         kill -2 $gdb_pid 2> /dev/null
285         {
286             sleep 5s ;
287             if kill -0 $gdb_pid 2> /dev/null ; then
288                 kill -9 $gdb_pid 2> /dev/null ;
289             fi
290             if kill -0 $serial_pid 2> /dev/null ; then
291                 kill -9 $serial_pid 2> /dev/null ;
292             fi
293         } &
294     } &
295     wait $gdb_pid
296     gdb_status=$?
297     {
298         if kill -0 $serial_pid 2> /dev/null ; then
299             kill $serial_pid 2> /dev/null ;
300         fi
301         sleep 5s ;
302         if kill -0 $serial_pid 2> /dev/null ; then
303             kill -9 $serial_pid 2> /dev/null ;
304         fi
305     } &
306     if [ $gdb_status -ge 128 ] ; then
307         ran_too_long="yes" ;
308     else
309         ran_too_long="no"
310     fi
311     if [ $gdb_status -ne 0 ] ; then
312         test_failed="yes" ;
313     else
314         test_failed="no"
315     fi
316     gdb_pid=""
317     serial_pid=""
318   fi
319
320   # Create the info files
321   {
322       echo "$date"
323       echo "Test run on: `uname -n`"
324       echo "Host Information:"
325       echo `uname -a`
326       echo
327       echo "Serial port: ${serial_device}"
328       echo "Baud rate:   ${baudrate}"
329       echo "BDM port:    ${bdm_device}"
330       echo "gdb:         `type -path ${gdbprog}`"
331
332       cat ${logfile}
333
334       if [ "$test_failed" = "yes" ] ; then
335           echo -e "\\n\\nTest did not finish normally"
336           if [ "$ran_too_long" = "yes" ] ; then
337               echo "Test killed after $max_run_time seconds"
338           fi
339       fi
340
341       echo
342       date;
343   } > ${infofile}
344   if [ "${debugging}" = "no" ] ; then
345       rm -f ${scriptfile}
346       rm -f ${gdblogfile}
347   fi
348done
349
350echo "Tests completed at " `date`
351test_exit 0
Note: See TracBrowser for help on using the repository browser.