1 | #!/bin/sh -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.OARcorp.com/rtems/license.html. |
---|
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 | simulator=mipstx39-rtems-run |
---|
89 | |
---|
90 | while getopts vdl:o:s: OPT |
---|
91 | do |
---|
92 | case "$OPT" in |
---|
93 | v) |
---|
94 | verbose="yes";; |
---|
95 | d) |
---|
96 | device_and_exit="yes" |
---|
97 | run_to_completion="no" |
---|
98 | stdio_setup="no";; |
---|
99 | l) |
---|
100 | logdir="$OPTARG";; |
---|
101 | o) |
---|
102 | extra_options="$OPTARG";; |
---|
103 | s) |
---|
104 | simulator="$OPTARG";; |
---|
105 | *) |
---|
106 | fatal;; |
---|
107 | esac |
---|
108 | done |
---|
109 | |
---|
110 | let $((shiftcount = $OPTIND - 1)) |
---|
111 | shift $shiftcount |
---|
112 | |
---|
113 | args=$* |
---|
114 | |
---|
115 | # |
---|
116 | # Check some parameters |
---|
117 | # |
---|
118 | |
---|
119 | # JRS CHANGE |
---|
120 | # if [ ! -x ${simulator} ] ; then |
---|
121 | # fatal "${simulator} is not executable" |
---|
122 | # fi; |
---|
123 | |
---|
124 | # |
---|
125 | # Run the tests |
---|
126 | # |
---|
127 | |
---|
128 | tests="$args" |
---|
129 | if [ ! "$tests" ] |
---|
130 | then |
---|
131 | set -- `echo *.exe` |
---|
132 | tests="$*" |
---|
133 | fi |
---|
134 | |
---|
135 | [ -d $logdir ] || |
---|
136 | mkdir $logdir || fatal "could not create log directory ($logdir)" |
---|
137 | |
---|
138 | # where the tmp files go |
---|
139 | trap "test_exit" 1 2 3 13 14 15 |
---|
140 | |
---|
141 | for tfile in $tests |
---|
142 | do |
---|
143 | |
---|
144 | tname=`basename $tfile .exe` |
---|
145 | cpus="1" |
---|
146 | TEST_TYPE="single" |
---|
147 | |
---|
148 | case $tname in |
---|
149 | # size is no longer interactive. |
---|
150 | monitor*| termios*) |
---|
151 | if [ $run_to_completion = "yes" ] |
---|
152 | then |
---|
153 | warn "Skipping $tname; it is interactive" |
---|
154 | continue |
---|
155 | fi |
---|
156 | ;; |
---|
157 | *-node2*) |
---|
158 | warn "Skipping $tname; 'runtest' runs both nodes when for *-node1" |
---|
159 | continue;; |
---|
160 | *-node1*) |
---|
161 | warn "Running both nodes associated with $tname" |
---|
162 | variant=`echo $tname | sed 's/.*-node[12]//' | sed 's/\.exe//'` |
---|
163 | tname=`echo $tname | sed 's/-node.*//'` |
---|
164 | TEST_TYPE="mp" |
---|
165 | ;; |
---|
166 | minimum*|stackchk*|spfatal*|termio*) |
---|
167 | continue |
---|
168 | ;; |
---|
169 | esac |
---|
170 | |
---|
171 | if [ $TEST_TYPE = "mp" ] |
---|
172 | then |
---|
173 | cpus="1 2" |
---|
174 | |
---|
175 | logfile1=$logdir/${tname}_1${variant} |
---|
176 | logfile2=$logdir/${tname}_2${variant} |
---|
177 | infofile1=$logfile1.info |
---|
178 | infofile2=$logfile2.info |
---|
179 | |
---|
180 | rm -f ${logfile1} ${logfile2} |
---|
181 | |
---|
182 | date=`date` |
---|
183 | echo "Starting $tname at $date" |
---|
184 | |
---|
185 | ${simulator} --board=jmr3904 ${tname}-node1${variant}.exe | \ |
---|
186 | sed -e 's/
//' -e '/^$/d' > ${logfile1} & |
---|
187 | |
---|
188 | ${simulator} --board=jmr3904 ${tname}-node2${variant}.exe | \ |
---|
189 | sed -e 's/
//' -e '/^$/d' > ${logfile2} & |
---|
190 | |
---|
191 | wait |
---|
192 | |
---|
193 | fi |
---|
194 | |
---|
195 | if [ $TEST_TYPE = "single" ] |
---|
196 | then |
---|
197 | logfile=$logdir/${tname}_1 |
---|
198 | infofile=$logfile.info |
---|
199 | |
---|
200 | rm -f ${logfile}.tmp* |
---|
201 | |
---|
202 | date=`date` |
---|
203 | echo "Starting $tname at $date" |
---|
204 | |
---|
205 | # Generate a device file to get the work done. |
---|
206 | # The device file must do the following: |
---|
207 | # |
---|
208 | # arrange for more memory (2 Mb) |
---|
209 | |
---|
210 | if [ "$device_and_exit" = "yes" ] |
---|
211 | then |
---|
212 | fatal "Cannot currently generate device files" |
---|
213 | fi |
---|
214 | |
---|
215 | # Spin off the simulator in the background |
---|
216 | # -c sets an instruction limit |
---|
217 | |
---|
218 | # XXX need to make sure it won't run forever... |
---|
219 | |
---|
220 | ${simulator} --board=jmr3904 $tfile | \ |
---|
221 | sed -e 's/
//' -e '/^$/d' > ${logfile} |
---|
222 | fi |
---|
223 | |
---|
224 | # Create the info files |
---|
225 | for cpu in $cpus |
---|
226 | do |
---|
227 | { |
---|
228 | echo "$date" |
---|
229 | echo "Test run on: `uname -n`" |
---|
230 | echo "Host Information:" |
---|
231 | echo `uname -a` |
---|
232 | echo |
---|
233 | |
---|
234 | #sed -e 's/
//' < ${logdir}/${tname}_${cpu} |
---|
235 | cat ${logdir}/${tname}_${cpu} |
---|
236 | |
---|
237 | if [ "$ran_too_long" = "yes" ] |
---|
238 | then |
---|
239 | echo "Test did NOT finish normally; killed after $max_run_time seconds" |
---|
240 | fi |
---|
241 | |
---|
242 | echo |
---|
243 | date; |
---|
244 | } > ${logdir}/${tname}_${cpu}.info |
---|
245 | done |
---|
246 | |
---|
247 | if [ "$cpus" = "1" ] |
---|
248 | then |
---|
249 | mv ${infofile} $logdir/${tname}.info |
---|
250 | mv ${logfile} $logdir/${tname} |
---|
251 | fi |
---|
252 | |
---|
253 | done |
---|
254 | |
---|
255 | echo "Tests completed at " `date` |
---|
256 | test_exit 0 |
---|
257 | |
---|
258 | # Local Variables: *** |
---|
259 | # mode:ksh *** |
---|
260 | # End: *** |
---|
261 | |
---|