jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 1 | #!/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 | |
| 20 | prog="$0" |
| 21 | while [ -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 |
| 30 | done |
| 31 | oldwd=`pwd` |
| 32 | progdir=`dirname "${prog}"` |
| 33 | cd "${progdir}" |
| 34 | progdir=`pwd` |
| 35 | prog="${progdir}"/`basename "${prog}"` |
| 36 | cd "${oldwd}" |
| 37 | |
| 38 | libdir=`dirname $progdir`/framework |
| 39 | |
| 40 | javaOpts="" |
| 41 | while expr "x$1" : 'x-J' >/dev/null; do |
| 42 | opt=`expr "$1" : '-J\(.*\)'` |
| 43 | javaOpts="${javaOpts} -${opt}" |
| 44 | shift |
| 45 | done |
| 46 | |
| 47 | |
| 48 | ####################################################################### |
| 49 | # Original content of invocation script follows. Uses values cleverly |
| 50 | # deduced by the above code. |
| 51 | ####################################################################### |
| 52 | |
| 53 | selection=$1 |
| 54 | interpreter="fast" |
| 55 | if [ "$selection" = "--portable" ]; then |
| 56 | selection=$2; |
| 57 | interpreter="portable" |
| 58 | fi |
| 59 | |
Jeff Hao | 7b74608 | 2013-11-12 10:57:03 -0800 | [diff] [blame] | 60 | dalviktest=$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 61 | dalviktestdir=$dalviktest/tests |
| 62 | dexcore=$dalviktest/tests/dot/junit/dexcore.jar |
Jeff Hao | 7b74608 | 2013-11-12 10:57:03 -0800 | [diff] [blame] | 63 | scriptdata=$dalviktestdir/data/scriptdata |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 64 | report=$dalviktest/report.html |
| 65 | curdate=`date` |
| 66 | curmode="" |
| 67 | datadir=/tmp/${USER} |
| 68 | base=$OUT |
| 69 | framework=$base/system/framework |
| 70 | export ANDROID_PRINTF_LOG=tag |
| 71 | export ANDROID_LOG_TAGS='*:s' # was: jdwp:i dalvikvm:i dalvikvmi:i' |
| 72 | export ANDROID_DATA=$datadir |
| 73 | export ANDROID_ROOT=$base/system |
| 74 | export LD_LIBRARY_PATH=$base/system/lib |
| 75 | export DYLD_LIBRARY_PATH=$base/system/lib |
| 76 | debug_opts="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" |
Brian Carlstrom | 7bc9ec2 | 2013-06-18 10:01:39 -0700 | [diff] [blame] | 77 | exe=$base/system/bin/dalvikvm |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 78 | bpath=$framework/core.jar |
| 79 | |
| 80 | echo "--------------------------------------------------" |
| 81 | echo "Dalvik VM Test Suite" |
| 82 | echo "Version 1.0" |
| 83 | echo "Copyright (c) 2008 The Android Open Source Project" |
| 84 | echo "" |
| 85 | |
| 86 | if [ "$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; |
| 97 | fi |
| 98 | |
| 99 | rm -rf --preserve-root $datadir/dalvik-cache |
| 100 | mkdir -p $datadir |
| 101 | mkdir -p $datadir/dalvik-cache |
| 102 | |
| 103 | if [ "$TARGET_SIMULATOR" = "true" ]; then |
| 104 | echo "Simulator mode, $interpreter interpreter"; |
| 105 | curmode="simulator" |
| 106 | else |
| 107 | echo "Emulator mode, $interpreter interpreter"; |
| 108 | curmode="emulator" |
| 109 | fi |
| 110 | |
| 111 | echo "" |
| 112 | |
| 113 | pre_report="<html><head><style> |
| 114 | table tr.ok { background:#a0ffa0; } |
| 115 | table tr.nok { background:#ffa0a0; } |
| 116 | table tr.wok { background:#ffffa0; } |
| 117 | table tr.lok { background:#aaaaff; } |
| 118 | </style></head> |
| 119 | <body> |
| 120 | <h1>Dalvik VM test suite results</h1> |
| 121 | Generated $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>" |
| 125 | post_report="</body></html>" |
| 126 | |
| 127 | rm -f $report |
| 128 | echo $pre_report > $report |
| 129 | |
| 130 | # ----------- running each opcode test ------------ |
| 131 | |
| 132 | export jpassedcnt=0 |
| 133 | export jfailedcnt=0 |
| 134 | export jvfefailedcnt=0 |
| 135 | export jwarningcnt=0 |
| 136 | export jallcnt=0 |
| 137 | export jcolumns=0 |
| 138 | |
| 139 | # TODO unhack |
| 140 | if [ "$TARGET_SIMULATOR" = "true" ]; then |
| 141 | echo -n "" |
| 142 | else |
Jeff Hao | 7b74608 | 2013-11-12 10:57:03 -0800 | [diff] [blame] | 143 | adb push $dexcore /data/local/tmp/dexcore.jar >> /dev/null 2>&1 |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 144 | fi |
| 145 | |
| 146 | function classnameToJar() |
| 147 | { |
| 148 | echo $1 | sed -e 's#\.#/#g;s#$#.jar#' |
| 149 | } |
| 150 | |
| 151 | while read -u 3 myline; |
| 152 | do |
| 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 |
wsmlby | c3605c0 | 2014-05-19 15:41:03 -0700 | [diff] [blame] | 184 | $valgrind $exe -Xmx512M -Xss32K -Xbootclasspath:$bpath $debug_opts \ |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 185 | -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 Hao | 7b74608 | 2013-11-12 10:57:03 -0800 | [diff] [blame] | 192 | classpath="/data/local/tmp/dexcore.jar" |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 193 | deps=${deps}" "${mainclass} |
| 194 | pushedjars="" |
| 195 | for dep in ${deps}; do |
| 196 | depJar=`classnameToJar ${dep}` |
| 197 | depFileName=`basename ${depJar}` |
Jeff Hao | 7b74608 | 2013-11-12 10:57:03 -0800 | [diff] [blame] | 198 | deviceFileName=/data/local/tmp/${depFileName} |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 199 | adb push ${depJar} ${deviceFileName} &> /dev/null |
| 200 | classpath=${classpath}:${deviceFileName} |
| 201 | pushedjars=${pushedjars}" "${deviceFileName} |
| 202 | done |
| 203 | |
Brian Carlstrom | 7bc9ec2 | 2013-06-18 10:01:39 -0700 | [diff] [blame] | 204 | adb shell dalvikvm -Djava.io.tmpdir=/data/local/tmp \ |
jeffhao | 4d25a2b | 2012-06-19 15:57:00 -0700 | [diff] [blame] | 205 | -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). |
| 259 | done 3<$scriptdata |
| 260 | |
| 261 | echo "</table>" >> $report |
| 262 | let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt |
| 263 | if [ $jallcalccnt -ne $jallcnt ]; then |
| 264 | echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report |
| 265 | exit 1; |
| 266 | fi |
| 267 | |
| 268 | echo $post_report >> $report |
| 269 | |
| 270 | echo "<br>Tests run: ${jallcnt}" >> $report |
| 271 | echo "<br>Functional failures: ${jfailedcnt}" >> $report |
| 272 | echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report |
| 273 | echo "<br>Console errors: ${jwarningcnt}" >> $report |
| 274 | |
| 275 | echo $post_report >> $report |
| 276 | |
| 277 | if [[ jcolumns -ne 0 ]]; then |
| 278 | echo "" |
| 279 | fi |
| 280 | |
| 281 | echo "" |
| 282 | |
| 283 | if [[ jallcnt -eq jpassedcnt ]]; then |
| 284 | echo "OK (${jpassedcnt} tests)" |
| 285 | else |
| 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}" |
| 292 | fi |
| 293 | |
| 294 | echo "" |
| 295 | echo "Please see complete report in ${report}" |
| 296 | echo "--------------------------------------------------" |