source: rtems/c/src/lib/libbsp/arm/nds/tools/runtest @ 15ca4e7

4.115
Last change on this file since 15ca4e7 was 15ca4e7, checked in by Joel Sherrill <joel.sherrill@…>, on 01/28/11 at 20:29:35

2011-01-28 Joel Sherrill <joel.sherrilL@…>

  • gba/clock/clockdrv.c, gba/console/conio.c, gba/console/console.c, gba/console/defaultfont.h, gba/include/arm_mode_bits.h, gba/include/asm_macros.h, gba/include/bsp.h, gba/include/conio.h, gba/include/gba.h, gba/include/gba_registers.h, gba/irq/irq.c, gba/irq/irq.h, gba/startup/bspstart.c, gba/timer/timer.c, gp32/include/bsp.h, gp32/startup/bspreset.c, gp32/startup/bspstart.c, nds/tools/runtest, shared/comm/uart.c, shared/comm/uart.h, smdk2410/include/bsp.h: Fix typo where license said found in found in.
  • Property mode set to 100755
File size: 5.0 KB
Line 
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 the file LICENSE in this distribution or at
13#  http://www.rtems.com/license/LICENSE.
14#
15#  $Id$
16#
17
18# progname=`basename $0`
19progname=${0##*/}        # fast basename hack for ksh, bash
20
21USAGE=\
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
33set -a
34
35#   log an error to stderr
36prerr()
37{
38    echo "$*" >&2
39}
40
41fatal() {
42    [ "$1" ] && prerr $*
43    prerr "$USAGE"
44    exit 1
45}
46
47warn() {
48    [ "$1" ] && prerr $*
49}
50
51# print args, 1 per line
52ml_echo()
53{
54    for l
55    do
56       echo "$l"
57    done
58}
59
60# run at normal and signalled exit
61test_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
79verbose=""
80extra_options=""
81device_and_exit=""
82stdio_setup="yes"
83run_to_completion="yes"
84logdir=log
85update_on_tick="no"
86max_run_time=$((5 * 60))
87using_print_buffer="yes"
88simulator=desmume
89
90while getopts vdl:o:s: OPT
91do
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
108done
109
110let $((shiftcount = $OPTIND - 1))
111shift $shiftcount
112
113args=$*
114
115#
116#  Check some parameters
117#
118
119#
120# Run the tests
121#
122
123tests="$args"
124if [ ! "$tests" ]
125then
126     set -- `echo *.exe`
127     tests="$*"
128fi
129
130[ -d $logdir ] ||
131  mkdir $logdir || fatal "could not create log directory ($logdir)"
132
133# where the tmp files go
134trap "test_exit" 1 2 3 13 14 15
135
136for tfile in $tests
137do
138
139   tname=`basename $tfile .exe`
140   cpus="1"
141   TEST_TYPE="single"
142
143   case $tname in
144       # size is no longer interactive.
145       capture* | monitor* | termios* | fileio* | pppd*)
146            if [ $run_to_completion = "yes" ]
147            then
148                 warn "Skipping $tname; it is interactive"
149                 continue
150            fi
151            ;;
152       *-node2*)
153           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
154           continue
155           ;;
156       *-node1*)
157           warn "Skipping $tname; is multiprocessor"
158           continue
159           ;;
160       minimum*|stackchk*|spfatal*|termio*)
161           continue
162           ;;
163   esac
164
165   if [ $TEST_TYPE = "single" ]
166   then
167     logfile=`pwd`/debug.log
168     infofile=$logfile.info
169
170     rm -f ${logfile}.tmp*
171
172     date=`date`
173     echo "Starting $tname at $date"
174
175     # Generate a device file to get the work done.
176     # The device file must do the following:
177     #
178     #       arrange for more memory (2 Mb)
179
180     if [ "$device_and_exit" = "yes" ]
181     then
182          fatal "Cannot currently generate device files"
183     fi
184
185     # Spin off the simulator in the background
186
187       ${simulator} `basename $tfile .exe`.nds 2>&1 >/dev/null &
188       pid=$!
189
190       # Make sure it won't run forever...
191       time_run=0
192       while [ $time_run -lt $max_run_time ]
193       do
194           # sleep 5s at a time waiting for job to finish or timer to expire
195           # if job has exited, then we exit, too.
196           sleep 5
197           kill -0 $pid 2> /dev/null
198           running=$?
199           if [ $running -eq 0 ]
200           then
201               time_run=$((time_run + 5))
202               if [ $time_run -ge $max_run_time ]
203               then
204                   kill -9 $pid 2> /dev/null
205                   ran_too_long="yes"
206               fi
207           else
208               ran_too_long="no"
209               break
210           fi
211       done
212   fi
213
214   # Create the info files
215   for cpu in $cpus
216   do
217   {
218       echo "$date"
219       echo "Test run on: `uname -n`"
220       echo "Host Information:"
221       echo `uname -a`
222       echo
223
224       j=`grep -n '\*\*\* ' debug.log | head -1 | cut -d':' -f1`
225       k=`wc -l debug.log | cut -d' ' -f1`
226
227       tail -$((k-j+1)) debug.log | head -$((k-j))| sed 's/\r//g'
228
229       if [ "$ran_too_long" = "yes" ]
230       then
231           echo "Test did NOT finish normally; killed after $max_run_time seconds"
232       fi
233
234       echo
235       date;
236   } > ${logdir}/${tname}_${cpu}.info
237   done
238
239   if [ "$cpus" = "1" ]
240   then
241        mv ${logfile}  $logdir/${tname}
242   fi
243
244done
245
246echo "Tests completed at " `date`
247test_exit 0
248
249# Local Variables: ***
250# mode:ksh ***
251# End: ***
252
Note: See TracBrowser for help on using the repository browser.