1 | #!@KSH@ -p |
---|
2 | # |
---|
3 | # Run rtems tests on the powerpc simulator |
---|
4 | # This program generates a simulator script to run each test |
---|
5 | # Typically the test is then run, although it can be generated |
---|
6 | # and left as a file using -s |
---|
7 | # |
---|
8 | # COPYRIGHT (c) 1989-1999. |
---|
9 | # On-Line Applications Research Corporation (OAR). |
---|
10 | # |
---|
11 | # The license and distribution terms for this file may be |
---|
12 | # found in found in the file LICENSE in this distribution or at |
---|
13 | # http://www.rtems.com/license/LICENSE. |
---|
14 | # |
---|
15 | # $Id$ |
---|
16 | # |
---|
17 | |
---|
18 | # progname=`basename $0` |
---|
19 | progname=${0##*/} # fast basename hack for ksh, bash |
---|
20 | |
---|
21 | USAGE=\ |
---|
22 | "usage: $progname [ -opts ] test [ test ... ] |
---|
23 | -o options -- specify options to be passed to simulator |
---|
24 | -v -- verbose |
---|
25 | -d -- generate device tree file (as 'test'.device) and exit |
---|
26 | -l logdir -- specify log directory (default is 'logdir') |
---|
27 | |
---|
28 | Specify test as 'test' or 'test.exe'. |
---|
29 | All multiprocessing tests *must* be specified simply as 'mp01', etc. |
---|
30 | " |
---|
31 | |
---|
32 | # export everything |
---|
33 | set -a |
---|
34 | |
---|
35 | # log an error to stderr |
---|
36 | prerr() |
---|
37 | { |
---|
38 | echo "$*" >&2 |
---|
39 | } |
---|
40 | |
---|
41 | fatal() { |
---|
42 | [ "$1" ] && prerr $* |
---|
43 | prerr "$USAGE" |
---|
44 | exit 1 |
---|
45 | } |
---|
46 | |
---|
47 | warn() { |
---|
48 | [ "$1" ] && prerr $* |
---|
49 | } |
---|
50 | |
---|
51 | # print args, 1 per line |
---|
52 | ml_echo() |
---|
53 | { |
---|
54 | for l |
---|
55 | do |
---|
56 | echo "$l" |
---|
57 | done |
---|
58 | } |
---|
59 | |
---|
60 | # run at normal and signalled exit |
---|
61 | test_exit() |
---|
62 | { |
---|
63 | exit_code=$1 |
---|
64 | |
---|
65 | rm -f ${logfile}.tmp* |
---|
66 | [ "$sim_pid" ] && kill -9 $sim_pid |
---|
67 | |
---|
68 | exit $exit_code |
---|
69 | } |
---|
70 | |
---|
71 | # |
---|
72 | # process the options |
---|
73 | # |
---|
74 | # defaults for getopt vars |
---|
75 | # |
---|
76 | # max_run_time is defaulted to 5 minutes |
---|
77 | # |
---|
78 | |
---|
79 | verbose="" |
---|
80 | extra_options="" |
---|
81 | device_and_exit="" |
---|
82 | stdio_setup="yes" |
---|
83 | run_to_completion="yes" |
---|
84 | logdir=log |
---|
85 | update_on_tick="no" |
---|
86 | max_run_time=$((5 * 60)) |
---|
87 | using_print_buffer="yes" |
---|
88 | txtarget=`echo @target_alias@ | sed -e 's/mips-/mipstx39-/'` |
---|
89 | simulator=${txtarget}-run |
---|
90 | |
---|
91 | while getopts vdl:o:s: OPT |
---|
92 | do |
---|
93 | case "$OPT" in |
---|
94 | v) |
---|
95 | verbose="yes";; |
---|
96 | d) |
---|
97 | device_and_exit="yes" |
---|
98 | run_to_completion="no" |
---|
99 | stdio_setup="no";; |
---|
100 | l) |
---|
101 | logdir="$OPTARG";; |
---|
102 | o) |
---|
103 | extra_options="$OPTARG";; |
---|
104 | s) |
---|
105 | simulator="$OPTARG";; |
---|
106 | *) |
---|
107 | fatal;; |
---|
108 | esac |
---|
109 | done |
---|
110 | |
---|
111 | let $((shiftcount = $OPTIND - 1)) |
---|
112 | shift $shiftcount |
---|
113 | |
---|
114 | args=$* |
---|
115 | |
---|
116 | # |
---|
117 | # Check some parameters |
---|
118 | # |
---|
119 | |
---|
120 | # JRS CHANGE |
---|
121 | # if [ ! -x ${simulator} ] ; then |
---|
122 | # fatal "${simulator} is not executable" |
---|
123 | # fi; |
---|
124 | |
---|
125 | # |
---|
126 | # Run the tests |
---|
127 | # |
---|
128 | |
---|
129 | tests="$args" |
---|
130 | if [ ! "$tests" ] |
---|
131 | then |
---|
132 | set -- `ls -1 *.exe *.ralf 2>/dev/null` |
---|
133 | tests="$*" |
---|
134 | fi |
---|
135 | |
---|
136 | [ -d $logdir ] || |
---|
137 | mkdir $logdir || fatal "could not create log directory ($logdir)" |
---|
138 | |
---|
139 | # where the tmp files go |
---|
140 | trap "test_exit" 1 2 3 13 14 15 |
---|
141 | |
---|
142 | for tfile in $tests |
---|
143 | do |
---|
144 | |
---|
145 | tname=`basename $tfile .exe` |
---|
146 | tname=`basename $tname .ralf` |
---|
147 | cpus="1" |
---|
148 | TEST_TYPE="single" |
---|
149 | |
---|
150 | case $tname in |
---|
151 | # size is no longer interactive. |
---|
152 | capture* | monitor* | termios* | fileio* | pppd*) |
---|
153 | if [ $run_to_completion = "yes" ] |
---|
154 | then |
---|
155 | warn "Skipping $tname; it is interactive" |
---|
156 | continue |
---|
157 | fi |
---|
158 | ;; |
---|
159 | *-node*) |
---|
160 | warn "Skipping $tname; MP tests not supported" |
---|
161 | continue |
---|
162 | ;; |
---|
163 | minimum*|stackchk*|*fatal*|termio*) |
---|
164 | continue |
---|
165 | ;; |
---|
166 | esac |
---|
167 | |
---|
168 | if [ $TEST_TYPE = "single" ] |
---|
169 | then |
---|
170 | logfile=$logdir/${tname}_1 |
---|
171 | infofile=$logfile.info |
---|
172 | |
---|
173 | rm -f ${logfile}.tmp* |
---|
174 | |
---|
175 | date=`date` |
---|
176 | echo "Starting $tname at $date" |
---|
177 | |
---|
178 | # Generate a device file to get the work done. |
---|
179 | # The device file must do the following: |
---|
180 | # |
---|
181 | # arrange for more memory (2 Mb) |
---|
182 | if [ "$device_and_exit" = "yes" ] |
---|
183 | then |
---|
184 | fatal "Cannot currently generate device files" |
---|
185 | fi |
---|
186 | |
---|
187 | # Spin off the simulator in the background |
---|
188 | |
---|
189 | ${simulator} --board=jmr3904 $tfile </dev/null > ${logfile} 2>&1 & |
---|
190 | pid=$! |
---|
191 | |
---|
192 | # Make sure it won't run forever... |
---|
193 | millilimit=`expr ${max_run_time} \* 1000` |
---|
194 | milliseconds=0 |
---|
195 | while : |
---|
196 | do |
---|
197 | # sleep 10ms at a time waiting for job to finish or timer to expire |
---|
198 | # if job has exited, then we exit, too. |
---|
199 | usleep 10000 # ten milliseconds |
---|
200 | milliseconds=`expr ${milliseconds} + 10` |
---|
201 | kill -0 $pid 2> /dev/null |
---|
202 | running=$? |
---|
203 | if [ $running -eq 0 ] ; then |
---|
204 | if [ ${milliseconds} -ge ${millilimit} ]; then |
---|
205 | kill -9 $pid 2> /dev/null |
---|
206 | #cat ${logfile} |
---|
207 | echo "${tname} killed after running ${max_run_time} seconds" |
---|
208 | break |
---|
209 | fi |
---|
210 | grep "^Unhandled exception" ${logfile} >/dev/null |
---|
211 | exceptionExit=$? |
---|
212 | grep "^mips-core: " ${logfile} >/dev/null |
---|
213 | badAccessExit=$? |
---|
214 | grep "^Warning, resuming with mismatched" ${logfile} >/dev/null |
---|
215 | simExceptExit=$? |
---|
216 | grep "^assertion" ${logfile} >/dev/null |
---|
217 | assertExit=$? |
---|
218 | if [ $badAccessExit -eq 0 -o $exceptionExit -eq 0 -o \ |
---|
219 | $simExceptExit -eq 0 -o $assertExit -eq 0 ] ; then |
---|
220 | kill -9 ${pid} >/dev/null 2>&1 |
---|
221 | #cat ${logfile} |
---|
222 | # echo Ran in ${milliseconds} milliseconds |
---|
223 | fi |
---|
224 | |
---|
225 | else |
---|
226 | # done normally |
---|
227 | # cat ${logfile} |
---|
228 | # echo "${tname} ran in ${milliseconds} milliseconds" |
---|
229 | break |
---|
230 | fi |
---|
231 | done |
---|
232 | fi |
---|
233 | |
---|
234 | # Create the info files |
---|
235 | for cpu in $cpus |
---|
236 | do |
---|
237 | { |
---|
238 | echo "$date" |
---|
239 | echo "Test run on: `uname -n`" |
---|
240 | echo "Host Information:" |
---|
241 | echo `uname -a` |
---|
242 | echo |
---|
243 | |
---|
244 | #sed -e 's/
//' < ${logdir}/${tname}_${cpu} |
---|
245 | cat ${logdir}/${tname}_${cpu} |
---|
246 | |
---|
247 | if [ "$ran_too_long" = "yes" ] |
---|
248 | then |
---|
249 | echo "Test did NOT finish normally; killed after $max_run_time seconds" |
---|
250 | fi |
---|
251 | |
---|
252 | echo |
---|
253 | date; |
---|
254 | } > ${logdir}/${tname}_${cpu}.info |
---|
255 | done |
---|
256 | |
---|
257 | if [ "$cpus" = "1" ] |
---|
258 | then |
---|
259 | sed -e 's/
//' -e '/^$/d' < ${infofile} >$logdir/${tname}.info |
---|
260 | sed -e 's/
//' -e '/^$/d' < ${logfile} >$logdir/${tname} |
---|
261 | fi |
---|
262 | |
---|
263 | done |
---|
264 | |
---|
265 | echo "Tests completed at " `date` |
---|
266 | test_exit 0 |
---|
267 | |
---|
268 | # Local Variables: *** |
---|
269 | # mode:ksh *** |
---|
270 | # End: *** |
---|
271 | |
---|