1 | #!@KSH@ -p |
---|
2 | # |
---|
3 | # $Id$ |
---|
4 | # |
---|
5 | # Run rtems tests on the SPARC simulator includeed with GDB |
---|
6 | # This program generates a simulator script to run each test |
---|
7 | # Typically the test is then run, although it can be generated |
---|
8 | # and left as a file using -s |
---|
9 | # |
---|
10 | |
---|
11 | # progname=`basename $0` |
---|
12 | progname=${0##*/} # fast basename hack for ksh, bash |
---|
13 | |
---|
14 | USAGE=\ |
---|
15 | "usage: $progname [ -opts ] test [ test ... ] |
---|
16 | -o options -- specify options to be passed to simulator |
---|
17 | -v -- verbose |
---|
18 | -s -- generate script file (as 'test'.ss) and exit |
---|
19 | -l logdir -- specify log directory (default is 'logdir') |
---|
20 | |
---|
21 | Specify test as 'test' or 'test.exe' or 'test.ralf'. |
---|
22 | All multiprocessing tests *must* be specified simply as 'mp01', etc. |
---|
23 | " |
---|
24 | |
---|
25 | # export everything |
---|
26 | set -a |
---|
27 | |
---|
28 | # log an error to stderr |
---|
29 | prerr() |
---|
30 | { |
---|
31 | echo "$*" >&2 |
---|
32 | } |
---|
33 | |
---|
34 | fatal() { |
---|
35 | [ "$1" ] && prerr $* |
---|
36 | prerr "$USAGE" |
---|
37 | exit 1 |
---|
38 | } |
---|
39 | |
---|
40 | warn() { |
---|
41 | [ "$1" ] && prerr $* |
---|
42 | } |
---|
43 | |
---|
44 | # print args, 1 per line |
---|
45 | ml_echo() |
---|
46 | { |
---|
47 | for l |
---|
48 | do |
---|
49 | echo "$l" |
---|
50 | done |
---|
51 | } |
---|
52 | |
---|
53 | # run at normal and signalled exit |
---|
54 | test_exit() |
---|
55 | { |
---|
56 | exit_code=$1 |
---|
57 | |
---|
58 | rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp* |
---|
59 | [ "$sim_pid" ] && kill -9 $sim_pid |
---|
60 | |
---|
61 | exit $exit_code |
---|
62 | } |
---|
63 | |
---|
64 | # |
---|
65 | # process the options |
---|
66 | # |
---|
67 | # defaults for getopt vars |
---|
68 | # |
---|
69 | # max_run_time is defaulted to 3 minutes |
---|
70 | # |
---|
71 | |
---|
72 | verbose="" |
---|
73 | extra_options="" |
---|
74 | script_and_exit="" |
---|
75 | stdio_setup="yes" |
---|
76 | run_to_completion="yes" |
---|
77 | logdir=log |
---|
78 | update_on_tick="no" |
---|
79 | max_run_time=$((3 * 60)) |
---|
80 | using_print_buffer="yes" |
---|
81 | |
---|
82 | while getopts vhr12o:c:sl:t OPT |
---|
83 | do |
---|
84 | case "$OPT" in |
---|
85 | v) |
---|
86 | verbose="yes";; |
---|
87 | s) |
---|
88 | script_and_exit="yes" |
---|
89 | run_to_completion="no" |
---|
90 | stdio_setup="no";; |
---|
91 | l) |
---|
92 | logdir="$OPTARG";; |
---|
93 | o) |
---|
94 | extra_options="$OPTARG";; |
---|
95 | *) |
---|
96 | fatal;; |
---|
97 | esac |
---|
98 | done |
---|
99 | |
---|
100 | let $((shiftcount = $OPTIND - 1)) |
---|
101 | shift $shiftcount |
---|
102 | |
---|
103 | args=$* |
---|
104 | |
---|
105 | # |
---|
106 | # Run the tests |
---|
107 | # |
---|
108 | |
---|
109 | tests="$args" |
---|
110 | if [ ! "$tests" ] |
---|
111 | then |
---|
112 | set -- `ls -1 *.exe *.ralf 2>/dev/null` |
---|
113 | tests="$*" |
---|
114 | fi |
---|
115 | |
---|
116 | [ -d $logdir ] || |
---|
117 | mkdir $logdir || fatal "could not create log directory ($logdir)" |
---|
118 | |
---|
119 | cpus=1 |
---|
120 | |
---|
121 | # where the tmp files go |
---|
122 | statfile=/tmp/stats$$ |
---|
123 | scriptfile=/tmp/script$$ |
---|
124 | |
---|
125 | trap "test_exit" 1 2 3 13 14 15 |
---|
126 | |
---|
127 | for tfile in $tests |
---|
128 | do |
---|
129 | |
---|
130 | echo $tfile | grep "exe$" >/dev/null |
---|
131 | if [ $? -eq 0 ] ; then |
---|
132 | ext=.exe |
---|
133 | else |
---|
134 | ext=.ralf |
---|
135 | fi |
---|
136 | tname=`basename $tfile ${ext}` |
---|
137 | TEST_TYPE="single" |
---|
138 | |
---|
139 | case $tname in |
---|
140 | capture* | monitor* | termios* | fileio* | pppd*) |
---|
141 | if [ $run_to_completion = "yes" ] |
---|
142 | then |
---|
143 | warn "Skipping $tname; it is interactive" |
---|
144 | continue |
---|
145 | fi |
---|
146 | ;; |
---|
147 | *-node2*) |
---|
148 | fatal "MP tests not supported" |
---|
149 | warn "Skipping $tname; 'runtest' runs both nodes when for *-node1" |
---|
150 | continue;; |
---|
151 | *-node1*) |
---|
152 | warn "Running both nodes associated with $tname" |
---|
153 | variant=`echo $tname | sed 's/.*-node[12]//' | sed "s/${ext}/"` |
---|
154 | tname=`echo $tname | sed 's/-node.*//'` |
---|
155 | TEST_TYPE="mp" |
---|
156 | ;; |
---|
157 | sp39*|sp41*) |
---|
158 | warn "Skipping $tname; it does not complete long on sis" |
---|
159 | continue |
---|
160 | ;; |
---|
161 | minimum*|stackchk*|*fatal*|termio*) |
---|
162 | warn "Skipping $tname; it locks up or takes a VERY long time to run" |
---|
163 | continue |
---|
164 | ;; |
---|
165 | esac |
---|
166 | |
---|
167 | # Change the title bar to indicate which test we are running |
---|
168 | # The simulator screen doesn't provide any indication |
---|
169 | |
---|
170 | logfile=$logdir/$tname |
---|
171 | infofile=$logfile.info |
---|
172 | |
---|
173 | rm -f ${statfile}* ${scriptfile}* ${logfile}.tmp* |
---|
174 | |
---|
175 | date=`date` |
---|
176 | echo "Starting $tname at $date" |
---|
177 | |
---|
178 | # Generate a script file to get the work done. |
---|
179 | # The script file must do the following: |
---|
180 | # |
---|
181 | # load the program (programs if MP test) |
---|
182 | # arrange for capture of output |
---|
183 | # run the program |
---|
184 | # produce statistics |
---|
185 | |
---|
186 | { |
---|
187 | case $TEST_TYPE in |
---|
188 | "mp") |
---|
189 | fatal "MP tests not supported" |
---|
190 | ;; |
---|
191 | |
---|
192 | # All other tests (single-processor) |
---|
193 | *) |
---|
194 | echo "load $tfile" |
---|
195 | echo "go 0x02000000" |
---|
196 | echo "" |
---|
197 | echo "perf" |
---|
198 | echo "quit" |
---|
199 | ;; |
---|
200 | esac |
---|
201 | |
---|
202 | } > ${scriptfile} |
---|
203 | |
---|
204 | if [ "$script_and_exit" = "yes" ] |
---|
205 | then |
---|
206 | mv ${scriptfile} $tname.ss |
---|
207 | warn "script left in $tname.ss" |
---|
208 | test_exit 0 |
---|
209 | fi |
---|
210 | |
---|
211 | # Spin off the simulator in the background |
---|
212 | sparc-rtems4.9-sis $extra_options -c ${scriptfile} >${logfile}.tmp & |
---|
213 | sim_pid=$! |
---|
214 | |
---|
215 | # Make sure it won't run forever... |
---|
216 | { |
---|
217 | time_run=0 |
---|
218 | while [ $time_run -lt $max_run_time ] |
---|
219 | do |
---|
220 | # sleep 1s at a time waiting for job to finish or timer to expire |
---|
221 | # if job has exited, then we exit, too. |
---|
222 | sleep 1 |
---|
223 | if kill -0 $sim_pid 2>/dev/null |
---|
224 | then |
---|
225 | grep "Memory exception " ${logfile}.tmp >/dev/null |
---|
226 | if [ $? -eq 0 ] ; then |
---|
227 | break |
---|
228 | fi |
---|
229 | |
---|
230 | time_run=$((time_run + 1)) |
---|
231 | else |
---|
232 | exit 0 |
---|
233 | fi |
---|
234 | done |
---|
235 | |
---|
236 | kill -2 $sim_pid 2>/dev/null |
---|
237 | { sleep 5; kill -9 $sim_pid 2>/dev/null; } & |
---|
238 | } & |
---|
239 | |
---|
240 | wait $sim_pid |
---|
241 | status=$? |
---|
242 | if [ $status -ne 0 ] |
---|
243 | then |
---|
244 | ran_too_long="yes" |
---|
245 | else |
---|
246 | ran_too_long="no" |
---|
247 | fi |
---|
248 | |
---|
249 | sim_pid="" |
---|
250 | |
---|
251 | # fix up the printf output from the test |
---|
252 | case $TEST_TYPE in |
---|
253 | mp) |
---|
254 | fatal "MP not supported" |
---|
255 | ;; |
---|
256 | *) |
---|
257 | output_it=1 |
---|
258 | grep -v "Memory exception " ${logfile}.tmp | \ |
---|
259 | sed -e '1,9d' \ |
---|
260 | -e 's/
//' -e '/^$/d' | \ |
---|
261 | while read line |
---|
262 | do |
---|
263 | if [ $output_it -eq 1 ] ; then |
---|
264 | if [ "$line" = "sis> perf" ] ; then |
---|
265 | output_it=0 |
---|
266 | elif [ "$line" = "sis> quit" ] ; then |
---|
267 | output_it=0 |
---|
268 | elif [ "$line" = "sis>" ] ; then |
---|
269 | output_it=0 |
---|
270 | else |
---|
271 | echo "$line" |
---|
272 | fi |
---|
273 | fi |
---|
274 | done > ${logfile}_1 |
---|
275 | ;; |
---|
276 | esac |
---|
277 | |
---|
278 | # Create the info files |
---|
279 | for cpu in $cpus |
---|
280 | do |
---|
281 | { |
---|
282 | echo "$date" |
---|
283 | echo "Test run on: `uname -n` ( `uname -a` )" |
---|
284 | |
---|
285 | output_it=0 |
---|
286 | grep -v "Memory exception " ${logfile}.tmp | \ |
---|
287 | sed -e 's/
//' | \ |
---|
288 | while read line |
---|
289 | do |
---|
290 | if [ $output_it -eq 1 ] ; then |
---|
291 | if [ "$line" = "sis> quit" ] ; then |
---|
292 | output_it=0 |
---|
293 | else |
---|
294 | echo "$line" |
---|
295 | fi |
---|
296 | else |
---|
297 | if [ "$line" = "sis> perf" ] ; then |
---|
298 | output_it=1 |
---|
299 | fi |
---|
300 | fi |
---|
301 | done |
---|
302 | |
---|
303 | |
---|
304 | if [ "$ran_too_long" = "yes" ] |
---|
305 | then |
---|
306 | echo "Test did NOT finish normally; killed after $max_run_time seconds" |
---|
307 | fi |
---|
308 | |
---|
309 | echo |
---|
310 | date; |
---|
311 | } > ${infofile}_$cpu |
---|
312 | done |
---|
313 | |
---|
314 | rm -f ${logfile}.tmp* |
---|
315 | |
---|
316 | if [ "$cpus" = "1" ] |
---|
317 | then |
---|
318 | mv ${infofile}_1 ${infofile} |
---|
319 | mv ${logfile}_1 ${logfile} |
---|
320 | fi |
---|
321 | |
---|
322 | done |
---|
323 | |
---|
324 | test_exit 0 |
---|
325 | |
---|
326 | # Local Variables: *** |
---|
327 | # mode:ksh *** |
---|
328 | # End: *** |
---|
329 | |
---|