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