OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 usage() { | 3 usage() { |
4 cat <<-EOF | 4 cat <<-EOF |
5 Usage: $0 [-rs] [-rj <board>] [-rh <board ip>] [tests] | 5 Usage: $0 [-rs] [-rj <board>] [-rh <board ip>] [tests] |
6 | 6 |
7 If no tests are specified, all tests are processed. | 7 If no tests are specified, all tests are processed. |
8 | 8 |
9 Options: | 9 Options: |
10 -rs Run on simulator | 10 -rs Run on simulator |
11 -rj <board> Run on board via JTAG | 11 -rj <board> Run on board via JTAG |
12 -rh <ip> Run on board ip | 12 -rh <ip> Run on board ip |
| 13 -j <num> Num jobs to run |
13 EOF | 14 EOF |
14 » exit ${0:-1} | 15 » exit ${1:-1} |
15 } | 16 } |
16 | 17 |
17 : ${MAKE:=make} | 18 : ${MAKE:=make} |
18 boardip= | 19 boardip= |
19 boardjtag= | 20 boardjtag= |
20 run_sim=false | 21 run_sim=false |
21 run_jtag=false | 22 run_jtag=false |
22 run_host=false | 23 run_host=false |
| 24 jobs=`getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1` |
| 25 : $(( jobs += 1 )) |
23 while [ -n "$1" ] ; do | 26 while [ -n "$1" ] ; do |
24 case $1 in | 27 case $1 in |
25 -rs) run_sim=true;; | 28 -rs) run_sim=true;; |
26 -rj) boardjtag=$2; shift; run_jtag=true;; | 29 -rj) boardjtag=$2; shift; run_jtag=true;; |
27 -rh) boardip=$2; shift; run_host=true;; | 30 -rh) boardip=$2; shift; run_host=true;; |
| 31 -j) jobs=$2; shift;; |
28 -*) usage;; | 32 -*) usage;; |
29 *) break;; | 33 *) break;; |
30 esac | 34 esac |
31 shift | 35 shift |
32 done | 36 done |
33 ${run_jtag} || ${run_host} || ${run_sim} || run_sim=true | 37 ${run_jtag} || ${run_host} || ${run_sim} || run_sim=true |
34 | 38 |
35 if ${run_host} && [ -z "${boardip}" ] ; then | 39 if ${run_host} && [ -z "${boardip}" ] ; then |
36 usage | 40 usage |
37 fi | 41 fi |
38 | 42 |
| 43 cd "${0%/*}" || exit 1 |
| 44 |
39 dorsh() { | 45 dorsh() { |
40 # rsh sucks and does not pass up its exit status, so we have to: | 46 # rsh sucks and does not pass up its exit status, so we have to: |
41 # on board: | 47 # on board: |
42 # - send all output to stdout | 48 # - send all output to stdout |
43 # - send exit status to stderr | 49 # - send exit status to stderr |
44 # on host: | 50 # on host: |
45 # - swap stdout and stderr | 51 # - swap stdout and stderr |
46 # - pass exit status to `exit` | 52 # - pass exit status to `exit` |
47 # - send stderr back to stdout and up | 53 # - send stderr back to stdout and up |
48 (exit \ | 54 (exit \ |
(...skipping 29 matching lines...) Expand all Loading... |
78 | 84 |
79 c | 85 c |
80 EOF | 86 EOF |
81 bfin-elf-gdb -x commands "$1" | 87 bfin-elf-gdb -x commands "$1" |
82 ret=$? | 88 ret=$? |
83 rm -f commands | 89 rm -f commands |
84 exit ${ret} | 90 exit ${ret} |
85 } | 91 } |
86 | 92 |
87 testit() { | 93 testit() { |
88 | |
89 local name=$1 x=$2 y=`echo $2 | sed 's:\.[xX]$::'` out rsh_out addr | 94 local name=$1 x=$2 y=`echo $2 | sed 's:\.[xX]$::'` out rsh_out addr |
90 shift; shift | 95 shift; shift |
91 local fail=`grep xfail ${y}` | 96 local fail=`grep xfail ${y}` |
92 if [ "${name}" = "HOST" -a ! -f $x ] ; then | 97 if [ "${name}" = "HOST" -a ! -f $x ] ; then |
93 return | 98 return |
94 fi | 99 fi |
95 printf '%-5s %-40s' ${name} ${x} | 100 printf '%-5s %-40s' ${name} ${x} |
96 out=`"$@" ${x} 2>&1` | 101 out=`"$@" ${x} 2>&1` |
97 (pf "${out}") | 102 (pf "${out}") |
98 if [ $? -ne 0 ] ; then | 103 if [ $? -ne 0 ] ; then |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 echo "SKIP $*" | 143 echo "SKIP $*" |
139 else | 144 else |
140 echo "FAIL! $*" | 145 echo "FAIL! $*" |
141 exit 1 | 146 exit 1 |
142 fi | 147 fi |
143 } | 148 } |
144 | 149 |
145 [ $# -eq 0 ] && set -- *.[Ss] | 150 [ $# -eq 0 ] && set -- *.[Ss] |
146 bins_hw=$( (${run_sim} || ${run_jtag}) && printf '%s.x ' "$@") | 151 bins_hw=$( (${run_sim} || ${run_jtag}) && printf '%s.x ' "$@") |
147 if ${run_host} ; then | 152 if ${run_host} ; then |
148 » for files in $@ | 153 » for files in "$@" ; do |
149 » do | |
150 tmp=`grep -e CYCLES -e TESTSET -e CLI -e STI -e RTX -e RTI -e SE
QSTAT $files -l` | 154 tmp=`grep -e CYCLES -e TESTSET -e CLI -e STI -e RTX -e RTI -e SE
QSTAT $files -l` |
151 if [ -z "${tmp}" ] ; then | 155 if [ -z "${tmp}" ] ; then |
152 bins_host=`echo "${bins_host} ${files}.X"` | 156 bins_host=`echo "${bins_host} ${files}.X"` |
153 else | 157 else |
154 echo "skipping ${files}, since it isn't userspace friend
ly" | 158 echo "skipping ${files}, since it isn't userspace friend
ly" |
155 fi | 159 fi |
156 done | 160 done |
157 fi | 161 fi |
158 if [ -n "${bins_hw}" ] ; then | 162 if [ -n "${bins_hw}" ] ; then |
159 bins_all="${bins_hw}" | 163 bins_all="${bins_hw}" |
(...skipping 27 matching lines...) Expand all Loading... |
187 pf | 191 pf |
188 fi | 192 fi |
189 | 193 |
190 if ${run_host} ; then | 194 if ${run_host} ; then |
191 printf 'Uploading tests to board "%s": ' "${boardip}" | 195 printf 'Uploading tests to board "%s": ' "${boardip}" |
192 rcp ${bins_host} root@${boardip}:/tmp/ | 196 rcp ${bins_host} root@${boardip}:/tmp/ |
193 pf | 197 pf |
194 rsh -l root $boardip '/bin/dmesg -c' > /dev/null | 198 rsh -l root $boardip '/bin/dmesg -c' > /dev/null |
195 fi | 199 fi |
196 | 200 |
| 201 SIM="../../../bfin/run" |
| 202 if [ ! -x ${SIM} ] ; then |
| 203 SIM="bfin-elf-run" |
| 204 fi |
| 205 echo "Using sim: ${SIM}" |
| 206 |
197 ret=0 | 207 ret=0 |
198 unexpected_fail=0 | 208 unexpected_fail=0 |
199 unexpected_pass=0 | 209 unexpected_pass=0 |
200 expected_pass=0 | 210 expected_pass=0 |
| 211 pids=() |
201 for s in "$@" ; do | 212 for s in "$@" ; do |
202 » ${run_sim} && testit SIM ${s}.x bfin-elf-run `sed -n '/^# sim:/s|^[^:]
*:||p' ${s}` | 213 » ( |
| 214 » out=$( |
| 215 » ${run_sim} && testit SIM ${s}.x ${SIM} `sed -n '/^# sim:/s|^[^:]*:||p'
${s}` |
203 ${run_jtag} && testit JTAG ${s}.x dojtag | 216 ${run_jtag} && testit JTAG ${s}.x dojtag |
204 ${run_host} && testit HOST ${s}.X dorsh | 217 ${run_host} && testit HOST ${s}.X dorsh |
| 218 ) |
| 219 case $out in |
| 220 *PASS*) ;; |
| 221 *) echo "$out" ;; |
| 222 esac |
| 223 ) & |
| 224 pids+=( $! ) |
| 225 if [[ ${#pids[@]} -gt ${jobs} ]] ; then |
| 226 wait ${pids[0]} |
| 227 pids=( ${pids[@]:1} ) |
| 228 fi |
205 done | 229 done |
| 230 wait |
206 | 231 |
207 killall -q bfin-gdbproxy | 232 killall -q bfin-gdbproxy |
208 if [ ${ret} -eq 0 ] ; then | 233 if [ ${ret} -eq 0 ] ; then |
209 rm -f gdbproxy.log | 234 rm -f gdbproxy.log |
210 » ${MAKE} -s clean & | 235 #» ${MAKE} -s clean & |
211 exit 0 | 236 exit 0 |
212 else | 237 else |
213 echo number of failures ${ret} | 238 echo number of failures ${ret} |
214 if [ ${unexpected_pass} -gt 0 ] ; then | 239 if [ ${unexpected_pass} -gt 0 ] ; then |
215 echo "Unexpected passes: ${unexpected_pass}" | 240 echo "Unexpected passes: ${unexpected_pass}" |
216 fi | 241 fi |
217 if [ ${unexpected_fail} -gt 0 ] ; then | 242 if [ ${unexpected_fail} -gt 0 ] ; then |
218 echo "Unexpected fails: ${unexpected_fail}" | 243 echo "Unexpected fails: ${unexpected_fail}" |
219 fi | 244 fi |
220 if [ ${expected_pass} -gt 0 ] ; then | 245 if [ ${expected_pass} -gt 0 ] ; then |
221 echo "passes : ${expected_pass}" | 246 echo "passes : ${expected_pass}" |
222 fi | 247 fi |
223 exit 1 | 248 exit 1 |
224 fi | 249 fi |
225 | |
OLD | NEW |