blob: be8fad49058b6f6b9e1a9d831bde0a46e87e5d5c [file] [log] [blame]
jeffhao4d25a2b2012-06-19 15:57:00 -07001#!/bin/bash
2#
3# Copyright (C) 2008 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Set up prog to be the path of this script, including following symlinks,
18# and set up progdir to be the fully-qualified pathname of its directory.
19
20prog="$0"
21while [ -h "${prog}" ]; do
22 newProg=`/bin/ls -ld "${prog}"`
23 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
24 if expr "x${newProg}" : 'x/' >/dev/null; then
25 prog="${newProg}"
26 else
27 progdir=`dirname "${prog}"`
28 prog="${progdir}/${newProg}"
29 fi
30done
31oldwd=`pwd`
32progdir=`dirname "${prog}"`
33cd "${progdir}"
34progdir=`pwd`
35prog="${progdir}"/`basename "${prog}"`
36cd "${oldwd}"
37
38libdir=`dirname $progdir`/framework
39
40javaOpts=""
41while expr "x$1" : 'x-J' >/dev/null; do
42 opt=`expr "$1" : '-J\(.*\)'`
43 javaOpts="${javaOpts} -${opt}"
44 shift
45done
46
47
48#######################################################################
49# Original content of invocation script follows. Uses values cleverly
50# deduced by the above code.
51#######################################################################
52
53selection=$1
54interpreter="fast"
55if [ "$selection" = "--portable" ]; then
56 selection=$2;
57 interpreter="portable"
58fi
59
Jeff Hao7b746082013-11-12 10:57:03 -080060dalviktest=$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates
jeffhao4d25a2b2012-06-19 15:57:00 -070061dalviktestdir=$dalviktest/tests
62dexcore=$dalviktest/tests/dot/junit/dexcore.jar
Jeff Hao7b746082013-11-12 10:57:03 -080063scriptdata=$dalviktestdir/data/scriptdata
jeffhao4d25a2b2012-06-19 15:57:00 -070064report=$dalviktest/report.html
65curdate=`date`
66curmode=""
67datadir=/tmp/${USER}
68base=$OUT
69framework=$base/system/framework
70export ANDROID_PRINTF_LOG=tag
71export ANDROID_LOG_TAGS='*:s' # was: jdwp:i dalvikvm:i dalvikvmi:i'
72export ANDROID_DATA=$datadir
73export ANDROID_ROOT=$base/system
74export LD_LIBRARY_PATH=$base/system/lib
75export DYLD_LIBRARY_PATH=$base/system/lib
76debug_opts="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
Brian Carlstrom7bc9ec22013-06-18 10:01:39 -070077exe=$base/system/bin/dalvikvm
jeffhao4d25a2b2012-06-19 15:57:00 -070078bpath=$framework/core.jar
79
80echo "--------------------------------------------------"
81echo "Dalvik VM Test Suite"
82echo "Version 1.0"
83echo "Copyright (c) 2008 The Android Open Source Project"
84echo ""
85
86if [ "$selection" = "--help" ]; then
87 echo "Usage: vm-tests [--help|--portable] [<mnemonic>]"
88 echo ""
89 echo " --help prints this help message"
90 echo " --portable uses the portable interpreter;"
91 echo " default is the fast one"
92 echo ""
93 echo " <mnemonic> specifies the instruction to test;"
94 echo " default is to run all tests"
95 echo ""
96 exit 1;
97fi
98
99rm -rf --preserve-root $datadir/dalvik-cache
100mkdir -p $datadir
101mkdir -p $datadir/dalvik-cache
102
103if [ "$TARGET_SIMULATOR" = "true" ]; then
104 echo "Simulator mode, $interpreter interpreter";
105 curmode="simulator"
106else
107 echo "Emulator mode, $interpreter interpreter";
108 curmode="emulator"
109fi
110
111echo ""
112
113pre_report="<html><head><style>
114table tr.ok { background:#a0ffa0; }
115table tr.nok { background:#ffa0a0; }
116table tr.wok { background:#ffffa0; }
117table tr.lok { background:#aaaaff; }
118</style></head>
119<body>
120<h1>Dalvik VM test suite results</h1>
121Generated $curdate (using the $curmode)
122<p>
123<table width='100%'>
124<tr><td>Status</td><td>Target</td><td>Category</td><td>Details</td></tr>"
125post_report="</body></html>"
126
127rm -f $report
128echo $pre_report > $report
129
130# ----------- running each opcode test ------------
131
132export jpassedcnt=0
133export jfailedcnt=0
134export jvfefailedcnt=0
135export jwarningcnt=0
136export jallcnt=0
137export jcolumns=0
138
139# TODO unhack
140if [ "$TARGET_SIMULATOR" = "true" ]; then
141 echo -n ""
142else
Jeff Hao7b746082013-11-12 10:57:03 -0800143 adb push $dexcore /data/local/tmp/dexcore.jar >> /dev/null 2>&1
jeffhao4d25a2b2012-06-19 15:57:00 -0700144fi
145
146function classnameToJar()
147{
148 echo $1 | sed -e 's#\.#/#g;s#$#.jar#'
149}
150
151while read -u 3 myline;
152do
153 # dot.junit.opcodes.add_double.Main_testB1;dot.junit.opcodes.add_double.d.T_add_double_1 ;opcode add_double;test B #1 (border edge case)
154 # ->
155 # mainclass: dot.junit.opcodes.add_double.Main_testB1
156 # testcasedir: opcodes/add_double
157 # testname: testB1 ->
158 # dir dot/junit/opcodes/add_double/testB1
159
160 # e.g dot.junit.opcodes.add_double.Main_testB1
161 mainclass=`echo $myline | cut -d";" -f1`
162 # e.g dot.junit.opcodes.add_double.d.T_add_double_1, space sep. >=1 entries
163 deps=`echo $myline | cut -d";" -f2`
164
165 jtitle=`echo $myline | cut -d";" -f3`
166 jcomment=`echo $myline | cut -d";" -f4`
167 details=`echo $myline | cut -d";" -f5`
168
169 if [ "$selection" == "" ] || [ "$jtitle" == "$selection" ]; then
170
171 (( jallcnt += 1 ))
172
173 cd $dalviktestdir
174 rm -f $datadir/dalvikout
175 # write dalvik output to file
176 echo -n "mk_b:" > $datadir/dalvikout
177
178 if [ "$TARGET_SIMULATOR" = "true" ]; then
179 classpath=`classnameToJar ${mainclass}`
180 for dep in ${deps}; do
181 depJar=`classnameToJar ${dep}`
182 classpath=${classpath}:${depJar}
183 done
wsmlbyc3605c02014-05-19 15:41:03 -0700184 $valgrind $exe -Xmx512M -Xss32K -Xbootclasspath:$bpath $debug_opts \
jeffhao4d25a2b2012-06-19 15:57:00 -0700185 -classpath $dexcore:$classpath $mainclass >> $datadir/dalvikout 2>&1
186
187 RESULTCODE=$?
188 if [ ${RESULTCODE} -ne 0 ]; then
189 echo "Dalvik VM failed, result=${RESULTCODE}" >> $datadir/dalvikout 2>&1
190 fi
191 else
Jeff Hao7b746082013-11-12 10:57:03 -0800192 classpath="/data/local/tmp/dexcore.jar"
jeffhao4d25a2b2012-06-19 15:57:00 -0700193 deps=${deps}" "${mainclass}
194 pushedjars=""
195 for dep in ${deps}; do
196 depJar=`classnameToJar ${dep}`
197 depFileName=`basename ${depJar}`
Jeff Hao7b746082013-11-12 10:57:03 -0800198 deviceFileName=/data/local/tmp/${depFileName}
jeffhao4d25a2b2012-06-19 15:57:00 -0700199 adb push ${depJar} ${deviceFileName} &> /dev/null
200 classpath=${classpath}:${deviceFileName}
201 pushedjars=${pushedjars}" "${deviceFileName}
202 done
203
Brian Carlstrom7bc9ec22013-06-18 10:01:39 -0700204 adb shell dalvikvm -Djava.io.tmpdir=/data/local/tmp \
jeffhao4d25a2b2012-06-19 15:57:00 -0700205 -classpath $classpath $mainclass >> $datadir/dalvikout 2>&1 && \
206 echo -n dvmpassed: >> $datadir/dalvikout 2>&1
207
208 for jar in ${pushedjars}; do
209 adb shell rm ${jar} &> /dev/null
210 done
211 fi
212
213 echo -n "mk_s:" >> $datadir/dalvikout
214 # Verify tmpout only contains mkdxc_start;mkdxc_stop -> no system.out/err
215 # because of exception. If ok -> green report line else red report with info
216 # between mkdxc_start and stop
217 vmresult=`cat $datadir/dalvikout`
218
219 if [[ ("$vmresult" == "mk_b:mk_s:") || ("$vmresult" == "mk_b:dvmpassed:mk_s:") ]]; then
220 (( jpassedcnt += 1 ))
221 echo -n "<tr class=\"ok\"><td>Success</td><td>$jtitle</td>" >> $report
222 echo "<td>$jcomment</td><td>$details</td></tr>" >> $report
223 echo -n "."
224 else
225 vmres=`cat $datadir/dalvikout | sed -e 's/mk_b://;s/mk_s://'`
226 vmres="$details<br><pre>$vmres</pre>"
227
228 stacktraces=`echo $vmresult | grep "java\.lang\." | grep -c "at dot\.junit\."`
229 if [[ $stacktraces > 0 ]]; then
230 jtype=`echo "$mainclass" | sed -e 's/.*_test\([^0-9]*\)[0-9].*/\1/' `
231 if [ "$jtype" == "VFE" ]; then
232 (( jvfefailedcnt += 1 ))
233 echo -n "V"
234 else
235 (( jfailedcnt += 1 ))
236 echo -n "F"
237 fi
238
239 echo "<tr class=\"nok\"><td>Failure</td><td>$jtitle</td><td>" >> $report
240 echo "$jcomment</td><td>$vmres</td></tr>" >> $report
241 else
242 (( jwarningcnt += 1 ))
243 echo "<tr class=\"wok\"><td>Failure</td><td>$jtitle</td><td>" >> $report
244 echo "$jcomment</td><td>(No stacktrace, but errors on console)" >> $report
245 echo "<br>$vmres</td></tr>" >> $report
246 echo -n "C"
247 fi
248 fi
249
250 (( jcolumns += 1 ))
251 if [ ${jcolumns} -eq 40 ]; then
252 echo ""
253 (( jcolumns = 0 ))
254 fi
255
256 fi
257# Use fd nr 3 to avoid subshelling via cat since this looses all
258# variables(and thus also the counters we are interested in).
259done 3<$scriptdata
260
261echo "</table>" >> $report
262let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt
263if [ $jallcalccnt -ne $jallcnt ]; then
264 echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report
265 exit 1;
266fi
267
268echo $post_report >> $report
269
270echo "<br>Tests run: ${jallcnt}" >> $report
271echo "<br>Functional failures: ${jfailedcnt}" >> $report
272echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report
273echo "<br>Console errors: ${jwarningcnt}" >> $report
274
275echo $post_report >> $report
276
277if [[ jcolumns -ne 0 ]]; then
278 echo ""
279fi
280
281echo ""
282
283if [[ jallcnt -eq jpassedcnt ]]; then
284 echo "OK (${jpassedcnt} tests)"
285else
286 echo "FAILURES!!!"
287 echo ""
288 echo "Tests run : ${jallcnt}"
289 echo "Functional failures: ${jfailedcnt}"
290 echo "Verifier failures : ${jvfefailedcnt}"
291 echo "Console errors : ${jwarningcnt}"
292fi
293
294echo ""
295echo "Please see complete report in ${report}"
296echo "--------------------------------------------------"