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-1998. |
---|
9 | # On-Line Applications Research Corporation (OAR). |
---|
10 | # Copyright assigned to U.S. Government, 1994. |
---|
11 | # |
---|
12 | # The license and distribution terms for this file may be |
---|
13 | # found in found in the file LICENSE in this distribution or at |
---|
14 | # http://www.OARcorp.com/rtems/license.html. |
---|
15 | # |
---|
16 | # $Id$ |
---|
17 | # |
---|
18 | |
---|
19 | # progname=`basename $0` |
---|
20 | progname=${0##*/} # fast basename hack for ksh, bash |
---|
21 | |
---|
22 | USAGE=\ |
---|
23 | "usage: $progname [ -opts ] test [ test ... ] |
---|
24 | -o options -- specify options to be passed to simulator |
---|
25 | -v -- verbose |
---|
26 | -d -- generate device tree file (as 'test'.device) and exit |
---|
27 | -l logdir -- specify log directory (default is 'logdir') |
---|
28 | |
---|
29 | Specify test as 'test' or 'test.exe'. |
---|
30 | All multiprocessing tests *must* be specified simply as 'mp01', etc. |
---|
31 | " |
---|
32 | |
---|
33 | # export everything |
---|
34 | set -a |
---|
35 | |
---|
36 | # log an error to stderr |
---|
37 | prerr() |
---|
38 | { |
---|
39 | echo "$*" >&2 |
---|
40 | } |
---|
41 | |
---|
42 | fatal() { |
---|
43 | [ "$1" ] && prerr $* |
---|
44 | prerr "$USAGE" |
---|
45 | exit 1 |
---|
46 | } |
---|
47 | |
---|
48 | warn() { |
---|
49 | [ "$1" ] && prerr $* |
---|
50 | } |
---|
51 | |
---|
52 | # print args, 1 per line |
---|
53 | ml_echo() |
---|
54 | { |
---|
55 | for l |
---|
56 | do |
---|
57 | echo "$l" |
---|
58 | done |
---|
59 | } |
---|
60 | |
---|
61 | # run at normal and signalled exit |
---|
62 | test_exit() |
---|
63 | { |
---|
64 | exit_code=$1 |
---|
65 | |
---|
66 | rm -f ${logfile}.tmp* |
---|
67 | [ "$sim_pid" ] && kill -9 $sim_pid |
---|
68 | |
---|
69 | exit $exit_code |
---|
70 | } |
---|
71 | |
---|
72 | # |
---|
73 | # process the options |
---|
74 | # |
---|
75 | # defaults for getopt vars |
---|
76 | # |
---|
77 | # max_run_time is defaulted to 5 minutes |
---|
78 | # |
---|
79 | |
---|
80 | verbose="" |
---|
81 | extra_options="" |
---|
82 | device_and_exit="" |
---|
83 | stdio_setup="yes" |
---|
84 | run_to_completion="yes" |
---|
85 | logdir=log |
---|
86 | update_on_tick="no" |
---|
87 | max_run_time=$((5 * 60)) |
---|
88 | using_print_buffer="yes" |
---|
89 | #simulator=/usr1/rtems/work/ada/4.00/ppc_src/b-gdb/sim/ppc/run |
---|
90 | simulator=powerpc-rtems-run |
---|
91 | instruction_limit=1000000000 |
---|
92 | sizeof_ram=4194304 |
---|
93 | |
---|
94 | while getopts vdl:o:s: OPT |
---|
95 | do |
---|
96 | case "$OPT" in |
---|
97 | v) |
---|
98 | verbose="yes";; |
---|
99 | d) |
---|
100 | device_and_exit="yes" |
---|
101 | run_to_completion="no" |
---|
102 | stdio_setup="no";; |
---|
103 | l) |
---|
104 | logdir="$OPTARG";; |
---|
105 | o) |
---|
106 | extra_options="$OPTARG";; |
---|
107 | r) |
---|
108 | sizeof_ram="$OPTARG";; |
---|
109 | s) |
---|
110 | simulator="$OPTARG";; |
---|
111 | *) |
---|
112 | fatal;; |
---|
113 | esac |
---|
114 | done |
---|
115 | |
---|
116 | let $((shiftcount = $OPTIND - 1)) |
---|
117 | shift $shiftcount |
---|
118 | |
---|
119 | args=$* |
---|
120 | |
---|
121 | # |
---|
122 | # Check some parameters |
---|
123 | # |
---|
124 | |
---|
125 | # JRS CHANGE |
---|
126 | # if [ ! -x ${simulator} ] ; then |
---|
127 | # fatal "${simulator} is not executable" |
---|
128 | # fi; |
---|
129 | |
---|
130 | # |
---|
131 | # Run the tests |
---|
132 | # |
---|
133 | |
---|
134 | tests="$args" |
---|
135 | if [ ! "$tests" ] |
---|
136 | then |
---|
137 | set -- `echo *.exe` |
---|
138 | tests="$*" |
---|
139 | fi |
---|
140 | |
---|
141 | [ -d $logdir ] || |
---|
142 | mkdir $logdir || fatal "could not create log directory ($logdir)" |
---|
143 | |
---|
144 | # where the tmp files go |
---|
145 | trap "test_exit" 1 2 3 13 14 15 |
---|
146 | |
---|
147 | for tfile in $tests |
---|
148 | do |
---|
149 | |
---|
150 | tname=`basename $tfile .exe` |
---|
151 | cpus="1" |
---|
152 | TEST_TYPE="single" |
---|
153 | |
---|
154 | case $tname in |
---|
155 | # size is no longer interactive. |
---|
156 | monitor*| termios*) |
---|
157 | if [ $run_to_completion = "yes" ] |
---|
158 | then |
---|
159 | warn "Skipping $tname; it is interactive" |
---|
160 | continue |
---|
161 | fi |
---|
162 | ;; |
---|
163 | *-node2*) |
---|
164 | warn "Skipping $tname; 'runtest' runs both nodes when for *-node1" |
---|
165 | continue;; |
---|
166 | *-node1*) |
---|
167 | warn "Running both nodes associated with $tname" |
---|
168 | tname=`echo $tname | sed 's/-node.*//'` |
---|
169 | TEST_TYPE="mp" |
---|
170 | ;; |
---|
171 | stackchk*|spfatal*|malloctest*) |
---|
172 | continue |
---|
173 | ;; |
---|
174 | esac |
---|
175 | |
---|
176 | if [ $TEST_TYPE = "mp" ] |
---|
177 | then |
---|
178 | cpus="1 2" |
---|
179 | |
---|
180 | logfile1=$logdir/${tname}_1 |
---|
181 | logfile2=$logdir/${tname}_2 |
---|
182 | infofile1=$logfile1.info |
---|
183 | infofile2=$logfile2.info |
---|
184 | |
---|
185 | rm -f ${logfile1} ${logfile2} |
---|
186 | |
---|
187 | date=`date` |
---|
188 | echo "Starting $tname at $date" |
---|
189 | |
---|
190 | ${simulator} $extra_options -c ${instruction_limit} \ |
---|
191 | -o "/#address-cells 2" \ |
---|
192 | -o "/openprom/options/oea-memory-size ${sizeof_ram}" \ |
---|
193 | -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \ |
---|
194 | -o "/shm@0xc0000000/key 0x1234" \ |
---|
195 | -o "/sem@0xc0010000/reg 0xc0010000 12" \ |
---|
196 | -o "/sem@0xc0010000/key 0x1234" \ |
---|
197 | -o "/sem@0xc0010000/value 1" ${tname}-node1.exe | \ |
---|
198 | sed -e 's/
//' -e '/^$/d' > ${logfile1} & |
---|
199 | |
---|
200 | ${simulator} $extra_options -c ${instruction_limit} \ |
---|
201 | -o "/#address-cells 2" \ |
---|
202 | -o "/openprom/options/oea-memory-size ${sizeof_ram}" \ |
---|
203 | -o "/shm@0xc0000000/reg 0xc0000000 0x10000" \ |
---|
204 | -o "/shm@0xc0000000/key 0x1234" \ |
---|
205 | -o "/sem@0xc0010000/reg 0xc0010000 12" \ |
---|
206 | -o "/sem@0xc0010000/key 0x1234" \ |
---|
207 | -o "/sem@0xc0010000/value -1" ${tname}-node2.exe | \ |
---|
208 | sed -e 's/
//' -e '/^$/d' > ${logfile2} & |
---|
209 | |
---|
210 | wait |
---|
211 | |
---|
212 | fi |
---|
213 | |
---|
214 | if [ $TEST_TYPE = "single" ] |
---|
215 | then |
---|
216 | logfile=$logdir/${tname}_1 |
---|
217 | infofile=$logfile.info |
---|
218 | |
---|
219 | rm -f ${logfile}.tmp* |
---|
220 | |
---|
221 | date=`date` |
---|
222 | echo "Starting $tname at $date" |
---|
223 | |
---|
224 | # Generate a device file to get the work done. |
---|
225 | # The device file must do the following: |
---|
226 | # |
---|
227 | # arrange for more memory (2 Mb) |
---|
228 | |
---|
229 | if [ "$device_and_exit" = "yes" ] |
---|
230 | then |
---|
231 | fatal "Cannot currently generate device files" |
---|
232 | fi |
---|
233 | |
---|
234 | # Spin off the simulator in the background |
---|
235 | # -c sets an instruction limit |
---|
236 | |
---|
237 | # Don't need to make sure it won't run forever... since there is |
---|
238 | # an instruction count limit |
---|
239 | |
---|
240 | #powerpc-rtems-run $extra_options -c ${instruction_limit} \ |
---|
241 | # -f ${devicefile} $tfile | sed -e 's/
//' -e '/^$/d' > ${logfile} |
---|
242 | |
---|
243 | ${simulator} $extra_options -c ${instruction_limit} \ |
---|
244 | -o "/#address-cells 2" \ |
---|
245 | -o "/openprom/options/oea-memory-size ${sizeof_ram}" \ |
---|
246 | $tfile | sed -e 's/
//' -e '/^$/d' > ${logfile} |
---|
247 | fi |
---|
248 | |
---|
249 | # Create the info files |
---|
250 | for cpu in $cpus |
---|
251 | do |
---|
252 | { |
---|
253 | echo "$date" |
---|
254 | echo "Test run on: `uname -n`" |
---|
255 | echo "Host Information:" |
---|
256 | echo `uname -a` |
---|
257 | echo |
---|
258 | |
---|
259 | #sed -e 's/
//' < ${logdir}/${tname}_${cpu} |
---|
260 | cat ${logdir}/${tname}_${cpu} |
---|
261 | |
---|
262 | if [ "$ran_too_long" = "yes" ] |
---|
263 | then |
---|
264 | echo "Test did NOT finish normally; killed after $max_run_time seconds" |
---|
265 | fi |
---|
266 | |
---|
267 | echo |
---|
268 | date; |
---|
269 | } > ${logdir}/${tname}_${cpu}.info |
---|
270 | done |
---|
271 | |
---|
272 | if [ "$cpus" = "1" ] |
---|
273 | then |
---|
274 | mv ${infofile} $logdir/${tname}.info |
---|
275 | mv ${logfile} $logdir/${tname} |
---|
276 | fi |
---|
277 | |
---|
278 | done |
---|
279 | |
---|
280 | echo "Tests completed at " `date` |
---|
281 | test_exit 0 |
---|
282 | |
---|
283 | # Local Variables: *** |
---|
284 | # mode:ksh *** |
---|
285 | # End: *** |
---|
286 | |
---|