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 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 60dalviktest=$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates 61dalviktestdir=$dalviktest/tests 62dexcore=$dalviktest/tests/dot/junit/dexcore.jar 63scriptdata=$dalviktestdir/data/scriptdata 64report=$dalviktest/report.html 65curdate=`date` 66datadir=/tmp/${USER} 67base=$OUT 68framework=$base/system/framework 69export ANDROID_PRINTF_LOG=tag 70export ANDROID_LOG_TAGS='*:s' # was: jdwp:i dalvikvm:i dalvikvmi:i' 71export ANDROID_DATA=$datadir 72export ANDROID_ROOT=$base/system 73export LD_LIBRARY_PATH=$base/system/lib 74export DYLD_LIBRARY_PATH=$base/system/lib 75debug_opts="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" 76exe=$base/system/bin/dalvikvm 77bpath=$framework/core.jar 78 79echo "--------------------------------------------------" 80echo "Dalvik VM Test Suite" 81echo "Version 1.0" 82echo "Copyright (c) 2008 The Android Open Source Project" 83echo "" 84 85if [ "$selection" = "--help" ]; then 86 echo "Usage: vm-tests [--help|--portable] [<mnemonic>]" 87 echo "" 88 echo " --help prints this help message" 89 echo " --portable uses the portable interpreter;" 90 echo " default is the fast one" 91 echo "" 92 echo " <mnemonic> specifies the instruction to test;" 93 echo " default is to run all tests" 94 echo "" 95 exit 1; 96fi 97 98rm -rf --preserve-root $datadir/dalvik-cache 99mkdir -p $datadir 100mkdir -p $datadir/dalvik-cache 101 102echo "" 103 104pre_report="<html><head><style> 105table tr.ok { background:#a0ffa0; } 106table tr.nok { background:#ffa0a0; } 107table tr.wok { background:#ffffa0; } 108table tr.lok { background:#aaaaff; } 109</style></head> 110<body> 111<h1>Dalvik VM test suite results</h1> 112Generated $curdate (using the emulator) 113<p> 114<table width='100%'> 115<tr><td>Status</td><td>Target</td><td>Category</td><td>Details</td></tr>" 116post_report="</body></html>" 117 118rm -f $report 119echo $pre_report > $report 120 121# ----------- running each opcode test ------------ 122 123export jpassedcnt=0 124export jfailedcnt=0 125export jvfefailedcnt=0 126export jwarningcnt=0 127export jallcnt=0 128export jcolumns=0 129 130# TODO unhack; dimitry: unhack what? 131adb push $dexcore /data/local/tmp/dexcore.jar >> /dev/null 2>&1 132 133function classnameToJar() 134{ 135 echo $1 | sed -e 's#\.#/#g;s#$#.jar#' 136} 137 138while read -u 3 myline; 139do 140 # 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) 141 # -> 142 # mainclass: dot.junit.opcodes.add_double.Main_testB1 143 # testcasedir: opcodes/add_double 144 # testname: testB1 -> 145 # dir dot/junit/opcodes/add_double/testB1 146 147 # e.g dot.junit.opcodes.add_double.Main_testB1 148 mainclass=`echo $myline | cut -d";" -f1` 149 # e.g dot.junit.opcodes.add_double.d.T_add_double_1, space sep. >=1 entries 150 deps=`echo $myline | cut -d";" -f2` 151 152 jtitle=`echo $myline | cut -d";" -f3` 153 jcomment=`echo $myline | cut -d";" -f4` 154 details=`echo $myline | cut -d";" -f5` 155 156 if [ "$selection" == "" ] || [ "$jtitle" == "$selection" ]; then 157 158 (( jallcnt += 1 )) 159 160 cd $dalviktestdir 161 rm -f $datadir/dalvikout 162 # write dalvik output to file 163 echo -n "mk_b:" > $datadir/dalvikout 164 165 classpath="/data/local/tmp/dexcore.jar" 166 deps=${deps}" "${mainclass} 167 pushedjars="" 168 for dep in ${deps}; do 169 depJar=`classnameToJar ${dep}` 170 depFileName=`basename ${depJar}` 171 deviceFileName=/data/local/tmp/${depFileName} 172 adb push ${depJar} ${deviceFileName} &> /dev/null 173 classpath=${classpath}:${deviceFileName} 174 pushedjars=${pushedjars}" "${deviceFileName} 175 done 176 177 adb shell dalvikvm -Djava.io.tmpdir=/data/local/tmp \ 178 -classpath $classpath $mainclass >> $datadir/dalvikout 2>&1 && \ 179 echo -n dvmpassed: >> $datadir/dalvikout 2>&1 180 181 for jar in ${pushedjars}; do 182 adb shell rm ${jar} &> /dev/null 183 done 184 185 echo -n "mk_s:" >> $datadir/dalvikout 186 # Verify tmpout only contains mkdxc_start;mkdxc_stop -> no system.out/err 187 # because of exception. If ok -> green report line else red report with info 188 # between mkdxc_start and stop 189 vmresult=`cat $datadir/dalvikout` 190 191 if [[ ("$vmresult" == "mk_b:mk_s:") || ("$vmresult" == "mk_b:dvmpassed:mk_s:") ]]; then 192 (( jpassedcnt += 1 )) 193 echo -n "<tr class=\"ok\"><td>Success</td><td>$jtitle</td>" >> $report 194 echo "<td>$jcomment</td><td>$details</td></tr>" >> $report 195 echo -n "." 196 else 197 vmres=`cat $datadir/dalvikout | sed -e 's/mk_b://;s/mk_s://'` 198 vmres="$details<br><pre>$vmres</pre>" 199 200 stacktraces=`echo $vmresult | grep "java\.lang\." | grep -c "at dot\.junit\."` 201 if [[ $stacktraces > 0 ]]; then 202 jtype=`echo "$mainclass" | sed -e 's/.*_test\([^0-9]*\)[0-9].*/\1/' ` 203 if [ "$jtype" == "VFE" ]; then 204 (( jvfefailedcnt += 1 )) 205 echo -n "V" 206 else 207 (( jfailedcnt += 1 )) 208 echo -n "F" 209 fi 210 211 echo "<tr class=\"nok\"><td>Failure</td><td>$jtitle</td><td>" >> $report 212 echo "$jcomment</td><td>$vmres</td></tr>" >> $report 213 else 214 (( jwarningcnt += 1 )) 215 echo "<tr class=\"wok\"><td>Failure</td><td>$jtitle</td><td>" >> $report 216 echo "$jcomment</td><td>(No stacktrace, but errors on console)" >> $report 217 echo "<br>$vmres</td></tr>" >> $report 218 echo -n "C" 219 fi 220 fi 221 222 (( jcolumns += 1 )) 223 if [ ${jcolumns} -eq 40 ]; then 224 echo "" 225 (( jcolumns = 0 )) 226 fi 227 228 fi 229# Use fd nr 3 to avoid subshelling via cat since this looses all 230# variables(and thus also the counters we are interested in). 231done 3<$scriptdata 232 233echo "</table>" >> $report 234let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt 235if [ $jallcalccnt -ne $jallcnt ]; then 236 echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report 237 exit 1; 238fi 239 240echo $post_report >> $report 241 242echo "<br>Tests run: ${jallcnt}" >> $report 243echo "<br>Functional failures: ${jfailedcnt}" >> $report 244echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report 245echo "<br>Console errors: ${jwarningcnt}" >> $report 246 247echo $post_report >> $report 248 249if [[ jcolumns -ne 0 ]]; then 250 echo "" 251fi 252 253echo "" 254 255if [[ jallcnt -eq jpassedcnt ]]; then 256 echo "OK (${jpassedcnt} tests)" 257else 258 echo "FAILURES!!!" 259 echo "" 260 echo "Tests run : ${jallcnt}" 261 echo "Functional failures: ${jfailedcnt}" 262 echo "Verifier failures : ${jvfefailedcnt}" 263 echo "Console errors : ${jwarningcnt}" 264fi 265 266echo "" 267echo "Please see complete report in ${report}" 268echo "--------------------------------------------------" 269