OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [unix/] [posix/] [tools/] [runtest.in] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
#!@KSH@ -p
2
#
3
# Run rtems tests on a POSIX-ish UNIX
4
#
5
#  $Id: runtest.in,v 1.2 2001-09-27 12:01:15 chris Exp $
6
#
7
 
8
trap "test_exit 1" 1 2 3 13 14 15
9
 
10
trap "test_exit 1" 1 2 3 13 14 15
11
 
12
# progname=`basename $0`
13
progname=${0##*/}        # fast basename hack for ksh, bash
14
 
15
USAGE=\
16
"usage: $progname [ -opts ] test [ test ... ]
17
        -c clicks   -- specify (hex) value for clicks / tick
18
        -v          -- verbose
19
        -l logdir   -- specify log directory (default is 'logdir')
20
 
21
  Specify test as 'test' or 'test.exe'.
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
killem()
54
{
55
    kill -9 $pid $pid1 $pid2 2> /dev/null
56
}
57
 
58
 
59
killem()
60
{
61
    kill -9 $pid $pid1 $pid2 2> /dev/null
62
}
63
 
64
 
65
test_exit()
66
{
67
    exit_code=$1
68
 
69
    killem
70
 
71
    killem
72
 
73
    rm -f ${logfile}.tmp*
74
 
75
    exit $exit_code
76
}
77
 
78
#
79
# process the options
80
#
81
# defaults for getopt vars
82
#
83
 
84
verbose=""
85
extra_options=""
86
clicks_per_tick=""
87
logdir=log
88
# how long can we run; rtems tests might run 300 seconds
89
max_run_time=400
90
run_to_completion="yes"
91
 
92
while getopts vo:c:l: OPT
93
do
94
    case "$OPT" in
95
        v)
96
            verbose="yes";;
97
        l)
98
            logdir="$OPTARG";;
99
        o)
100
            extra_options="$OPTARG";;
101
        c)
102
            clicks_per_tick="$OPTARG";;
103
        *)
104
            fatal;;
105
    esac
106
done
107
 
108
let $((shiftcount = $OPTIND - 1))
109
shift $shiftcount
110
 
111
args=$*
112
 
113
#
114
# Run the tests
115
#
116
 
117
tests="$args"
118
if [ ! "$tests" ]
119
then
120
     set -- `echo *.exe`
121
     tests="$*"
122
fi
123
 
124
[ -d $logdir ] || mkdir $logdir || fatal "could not create log directory ($logdir)"
125
 
126
for tfile in $tests
127
do
128
 
129
   tname=`echo $tfile | sed -e 's/\.exe$//'`
130
   tname=`basename $tname`
131
 
132
   TEST_TYPE="single"
133
 
134
   case $tname in
135
       monitor)
136
           if [ $run_to_completion = "yes" ]
137
           then
138
                warn "Skipping $tname; it is interactive"
139
                continue
140
           fi
141
           ;;
142
       *-node2*)
143
           warn "Skipping $tname; 'runtest' runs both nodes when for *-node1"
144
           continue;;
145
       *-node1*)
146
           tname=`echo $tname | sed 's/-node.*//'`
147
           warn "Running both nodes associated with $tname"
148
           TEST_TYPE="mp"
149
           ;;
150
       stackchk*|spfatal*|malloctest*|termio*)
151
           warn "Skipping $tname; it locks up or takes a VERY long time to run"
152
           continue
153
           ;;
154
   esac
155
 
156
   if [ $TEST_TYPE = "mp" ]
157
   then
158
       logfile1=$logdir/${tname}_1
159
       infofile1=$logfile1.info
160
       logfile2=$logdir/${tname}_2
161
       infofile2=$logfile2.info
162
 
163
       rm -f ${logfile1}
164
       rm -f ${logfile2}
165
 
166
       date=`date`
167
       echo "Starting $tname at $date"
168
 
169
       ./${tname}-node1.exe > $logfile1 2>&1 &
170
       pid1=$!
171
       ./${tname}-node2.exe > $logfile2 2>&1 &
172
       pid2=$!
173
 
174
       # Wait for both cpu's to complete, ensuring they don't run forever...
175
       time_run=0
176
       while [ $time_run -lt $max_run_time ]
177
       do
178
           # sleep 5s at a time waiting for jobs to finish or timer to expire
179
           # if job has exited, then we exit, too.
180
           sleep 5
181
           kill -0 $pid1 2> /dev/null
182
           running1=$?
183
           kill -0 $pid2 2> /dev/null
184
           running2=$?
185
           if [ $running1 -eq 0 ] && [ $running2 -eq 0 ]  # both still running
186
           then
187
               time_run=$((time_run + 5))
188
               if [ $time_run -ge $max_run_time ]
189
               then
190
                   echo "$tname ran too long; killing it"
191
                   ran_too_long="yes"
192
               fi
193
           else
194
               ran_too_long="no"
195
               # if one is still running, have to kill them
196
               if [ $running1 -ne $running2 ]
197
               then
198
                   sleep 10     # give other node a chance to gracefully die
199
               fi
200
               break
201
           fi
202
       done
203
 
204
       # make sure they are gone
205
       kill -9 $pid1 2> /dev/null
206
       kill -9 $pid2 2> /dev/null
207
   fi
208
 
209
   if [ $TEST_TYPE = "single" ]
210
   then
211
       logfile=$logdir/$tname
212
       infofile=$logfile.info
213
 
214
       rm -f ${logfile}
215
 
216
       date=`date`
217
       echo "Starting $tname.exe at $date"
218
 
219
       ./$tname.exe > $logfile 2>&1 &
220
       pid=$!
221
 
222
       # Make sure it won't run forever...
223
       time_run=0
224
       while [ $time_run -lt $max_run_time ]
225
       do
226
           # sleep 5s at a time waiting for job to finish or timer to expire
227
           # if job has exited, then we exit, too.
228
           sleep 5
229
           kill -0 $pid 2> /dev/null
230
           running=$?
231
           if [ $running -eq 0 ]
232
           then
233
               time_run=$((time_run + 5))
234
               if [ $time_run -ge $max_run_time ]
235
               then
236
                   kill -9 $pid 2> /dev/null
237
                   ran_too_long="yes"
238
               fi
239
           else
240
               ran_too_long="no"
241
               break
242
           fi
243
       done
244
   fi
245
 
246
   pid=""
247
 
248
done
249
 
250
test_exit 0
251
 
252
# Local Variables: ***
253
# mode:ksh ***
254
# End: ***
255
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.