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