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 found in the file LICENSE in this distribution or at |
---|
20 | # http://www.OARcorp.com/rtems/license.html. |
---|
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 | -r runname -- specify name of run program to be used |
---|
31 | -v -- verbose output |
---|
32 | -d -- don't remove temporary files (for debugging only) |
---|
33 | -l logdir -- specify log directory (default is 'logdir') |
---|
34 | |
---|
35 | Specify test as 'test' or 'test.exe'. |
---|
36 | All multiprocessing tests *must* be specified simply as 'mp01', etc. |
---|
37 | " |
---|
38 | |
---|
39 | # export everything |
---|
40 | set -a |
---|
41 | |
---|
42 | # log an error to stderr |
---|
43 | prerr() |
---|
44 | { |
---|
45 | echo "$*" >&2 |
---|
46 | } |
---|
47 | |
---|
48 | fatal() { |
---|
49 | [ "$1" ] && prerr $* |
---|
50 | prerr "$USAGE" |
---|
51 | exit 1 |
---|
52 | } |
---|
53 | |
---|
54 | warn() { |
---|
55 | [ "$1" ] && prerr $* |
---|
56 | } |
---|
57 | |
---|
58 | # run at normal and signalled exit |
---|
59 | test_exit() |
---|
60 | { |
---|
61 | exit_code=$1 |
---|
62 | |
---|
63 | rm -f ${logfile}.tmp* |
---|
64 | [ "$run_pid" ] && kill -9 $run_pid |
---|
65 | |
---|
66 | exit $exit_code |
---|
67 | } |
---|
68 | |
---|
69 | # |
---|
70 | # process the options |
---|
71 | # |
---|
72 | # defaults for getopt vars |
---|
73 | # |
---|
74 | # max_run_time is defaulted to 5 minutes |
---|
75 | # |
---|
76 | |
---|
77 | verbose="" |
---|
78 | runprog=sh-rtemself-run |
---|
79 | logdir=log |
---|
80 | max_run_time=$((10 * 60)) |
---|
81 | #sizeof_ram=$((1 * 1024 * 1024)) |
---|
82 | debugging="no" |
---|
83 | #console_mode=0 |
---|
84 | |
---|
85 | while getopts vdips:r:b:l: OPT |
---|
86 | do |
---|
87 | case "$OPT" in |
---|
88 | v) |
---|
89 | verbose="yes";; |
---|
90 | d) |
---|
91 | debugging="yes";; |
---|
92 | l) |
---|
93 | logdir="$OPTARG";; |
---|
94 | r) |
---|
95 | runprog="$OPTARG";; |
---|
96 | # p) |
---|
97 | # console_mode=1;; |
---|
98 | # i) |
---|
99 | # console_mode=2;; |
---|
100 | *) |
---|
101 | fatal;; |
---|
102 | esac |
---|
103 | done |
---|
104 | |
---|
105 | let $((shiftcount = $OPTIND - 1)) |
---|
106 | shift $shiftcount |
---|
107 | |
---|
108 | args=$* |
---|
109 | |
---|
110 | # |
---|
111 | # Run the tests |
---|
112 | # |
---|
113 | |
---|
114 | tests="$args" |
---|
115 | if [ ! "$tests" ] |
---|
116 | then |
---|
117 | set -- `echo *.exe` |
---|
118 | tests="$*" |
---|
119 | fi |
---|
120 | |
---|
121 | [ -d $logdir ] || |
---|
122 | mkdir $logdir || fatal "could not create log directory ($logdir)" |
---|
123 | |
---|
124 | # where the tmp files go |
---|
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 | cpus="1" |
---|
132 | TEST_TYPE="single" |
---|
133 | |
---|
134 | case "$tname" in |
---|
135 | # size is no longer interactive. |
---|
136 | monitor* | termios* | fileio*) |
---|
137 | warn "Skipping $tname; it is interactive" |
---|
138 | continue |
---|
139 | ;; |
---|
140 | *-node2*) |
---|
141 | warn "Skipping $tname; 'runtest' runs both nodes when for *-node1" |
---|
142 | continue |
---|
143 | ;; |
---|
144 | *-node1*) |
---|
145 | warn "Running both nodes associated with $tname" |
---|
146 | tname=`echo $tname | sed 's/-node.*//'` |
---|
147 | TEST_TYPE="mp" |
---|
148 | ;; |
---|
149 | minimum*|spfatal*) |
---|
150 | continue |
---|
151 | ;; |
---|
152 | esac |
---|
153 | |
---|
154 | if [ "$TEST_TYPE" = "mp" ] ; then |
---|
155 | fatal "MP tests not supported for this board" |
---|
156 | fi |
---|
157 | |
---|
158 | if [ $TEST_TYPE = "single" ] ; then |
---|
159 | logfile=$logdir/${tname} |
---|
160 | infofile=${logfile}.info |
---|
161 | # scriptfile=${logfile}.ss |
---|
162 | # runlogfile=${logfile}.run |
---|
163 | |
---|
164 | rm -f ${logfile}.tmp* |
---|
165 | |
---|
166 | date=`date` |
---|
167 | echo "Starting $tname at $date" |
---|
168 | |
---|
169 | ${runprog} "${tfile}" > "${logfile}" 2>&1 & |
---|
170 | run_pid=$! |
---|
171 | { |
---|
172 | time_run=0 |
---|
173 | while [ $time_run -lt $max_run_time ] ; do |
---|
174 | sleep 10s |
---|
175 | if kill -0 $run_pid 2> /dev/null ; then |
---|
176 | time_run=$((time_run+10)) ; |
---|
177 | else |
---|
178 | exit 0 |
---|
179 | fi |
---|
180 | done |
---|
181 | kill -2 $run_pid 2> /dev/null |
---|
182 | { |
---|
183 | sleep 5s ; |
---|
184 | if kill -0 $run_pid 2> /dev/null ; then |
---|
185 | kill -9 $run_pid 2> /dev/null ; |
---|
186 | fi |
---|
187 | } & |
---|
188 | } & |
---|
189 | wait $run_pid |
---|
190 | run_status=$? |
---|
191 | if [ $run_status -ge 128 ] ; then |
---|
192 | ran_too_long="yes" ; |
---|
193 | else |
---|
194 | ran_too_long="no" |
---|
195 | fi |
---|
196 | if [ $run_status -ne 0 ] ; then |
---|
197 | test_failed="yes" ; |
---|
198 | else |
---|
199 | test_failed="no" |
---|
200 | fi |
---|
201 | run_pid="" |
---|
202 | fi |
---|
203 | |
---|
204 | # Create the info files |
---|
205 | { |
---|
206 | echo "$date" |
---|
207 | echo "Test run on: `uname -n`" |
---|
208 | echo "Host Information:" |
---|
209 | echo `uname -a` |
---|
210 | echo |
---|
211 | echo "run: `type -path ${runprog}`" |
---|
212 | |
---|
213 | cat ${logfile} |
---|
214 | |
---|
215 | if [ "$test_failed" = "yes" ] ; then |
---|
216 | echo -e "\\n\\nTest did not finish normally" |
---|
217 | if [ "$ran_too_long" = "yes" ] ; then |
---|
218 | echo "Test killed after $max_run_time seconds" |
---|
219 | fi |
---|
220 | fi |
---|
221 | |
---|
222 | echo |
---|
223 | date; |
---|
224 | } > ${infofile} |
---|
225 | # if [ "${debugging}" = "no" ] ; then |
---|
226 | # rm -f ${runlogfile} |
---|
227 | # fi |
---|
228 | done |
---|
229 | |
---|
230 | echo "Tests completed at " `date` |
---|
231 | test_exit 0 |
---|