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 60 dalviktest=$progdir/../cts_dalviktests 61 dalviktestdir=$dalviktest/tests 62 dexcore=$dalviktest/tests/dot/junit/dexcore.jar 63 scriptdata=$dalviktest/data/scriptdata 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" 77 exe=$base/system/bin/dalvikvm 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 if [ -f $exe ]; then 107 version=`${exe} -version 2> /dev/null | grep -o "version.*$"` 108 echo "Using Dalvik VM ${version}" 109 else 110 echo "No Dalvik VM found at $exe"; 111 exit 1; 112 fi 113 else 114 echo "Emulator mode, $interpreter interpreter"; 115 curmode="emulator" 116 version=`adb shell dalvikvm -version 2> /dev/null | grep -o "version.*$"` 117 if [ "${version}" != "" ]; then 118 echo "Using Dalvik VM ${version}" 119 else 120 echo "No emulator or device found"; 121 exit 1; 122 fi 123 fi 124 125 echo "" 126 127 pre_report="<html><head><style> 128 table tr.ok { background:#a0ffa0; } 129 table tr.nok { background:#ffa0a0; } 130 table tr.wok { background:#ffffa0; } 131 table tr.lok { background:#aaaaff; } 132 </style></head> 133 <body> 134 <h1>Dalvik VM test suite results</h1> 135 Generated $curdate (using the $curmode) 136 <p> 137 <table width='100%'> 138 <tr><td>Status</td><td>Target</td><td>Category</td><td>Details</td></tr>" 139 post_report="</body></html>" 140 141 rm -f $report 142 echo $pre_report > $report 143 144 # ----------- running each opcode test ------------ 145 146 export jpassedcnt=0 147 export jfailedcnt=0 148 export jvfefailedcnt=0 149 export jwarningcnt=0 150 export jallcnt=0 151 export jcolumns=0 152 153 # TODO unhack 154 if [ "$TARGET_SIMULATOR" = "true" ]; then 155 echo -n "" 156 else 157 adb push $dexcore /data/dexcore.jar >> /dev/null 2>&1 158 fi 159 160 function classnameToJar() 161 { 162 echo $1 | sed -e 's#\.#/#g;s#$#.jar#' 163 } 164 165 while read -u 3 myline; 166 do 167 # 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) 168 # -> 169 # mainclass: dot.junit.opcodes.add_double.Main_testB1 170 # testcasedir: opcodes/add_double 171 # testname: testB1 -> 172 # dir dot/junit/opcodes/add_double/testB1 173 174 # e.g dot.junit.opcodes.add_double.Main_testB1 175 mainclass=`echo $myline | cut -d";" -f1` 176 # e.g dot.junit.opcodes.add_double.d.T_add_double_1, space sep. >=1 entries 177 deps=`echo $myline | cut -d";" -f2` 178 179 jtitle=`echo $myline | cut -d";" -f3` 180 jcomment=`echo $myline | cut -d";" -f4` 181 details=`echo $myline | cut -d";" -f5` 182 183 if [ "$selection" == "" ] || [ "$jtitle" == "$selection" ]; then 184 185 (( jallcnt += 1 )) 186 187 cd $dalviktestdir 188 rm -f $datadir/dalvikout 189 # write dalvik output to file 190 echo -n "mk_b:" > $datadir/dalvikout 191 192 if [ "$TARGET_SIMULATOR" = "true" ]; then 193 classpath=`classnameToJar ${mainclass}` 194 for dep in ${deps}; do 195 depJar=`classnameToJar ${dep}` 196 classpath=${classpath}:${depJar} 197 done 198 $valgrind $exe -Xint:$interpreter -Xmx512M -Xss32K -Xbootclasspath:$bpath $debug_opts \ 199 -classpath $dexcore:$classpath $mainclass >> $datadir/dalvikout 2>&1 200 201 RESULTCODE=$? 202 if [ ${RESULTCODE} -ne 0 ]; then 203 echo "Dalvik VM failed, result=${RESULTCODE}" >> $datadir/dalvikout 2>&1 204 fi 205 else 206 classpath="/data/dexcore.jar" 207 deps=${deps}" "${mainclass} 208 pushedjars="" 209 for dep in ${deps}; do 210 depJar=`classnameToJar ${dep}` 211 depFileName=`basename ${depJar}` 212 deviceFileName=/data/${depFileName} 213 adb push ${depJar} ${deviceFileName} &> /dev/null 214 classpath=${classpath}:${deviceFileName} 215 pushedjars=${pushedjars}" "${deviceFileName} 216 done 217 218 adb shell dalvikvm -Xint:$interpreter -Xmx512M -Xss32K -Djava.io.tmpdir=/data/local/tmp \ 219 -classpath $classpath $mainclass >> $datadir/dalvikout 2>&1 && \ 220 echo -n dvmpassed: >> $datadir/dalvikout 2>&1 221 222 for jar in ${pushedjars}; do 223 adb shell rm ${jar} &> /dev/null 224 done 225 fi 226 227 echo -n "mk_s:" >> $datadir/dalvikout 228 # Verify tmpout only contains mkdxc_start;mkdxc_stop -> no system.out/err 229 # because of exception. If ok -> green report line else red report with info 230 # between mkdxc_start and stop 231 vmresult=`cat $datadir/dalvikout` 232 233 if [[ ("$vmresult" == "mk_b:mk_s:") || ("$vmresult" == "mk_b:dvmpassed:mk_s:") ]]; then 234 (( jpassedcnt += 1 )) 235 echo -n "<tr class=\"ok\"><td>Success</td><td>$jtitle</td>" >> $report 236 echo "<td>$jcomment</td><td>$details</td></tr>" >> $report 237 echo -n "." 238 else 239 vmres=`cat $datadir/dalvikout | sed -e 's/mk_b://;s/mk_s://'` 240 vmres="$details<br><pre>$vmres</pre>" 241 242 stacktraces=`echo $vmresult | grep "java\.lang\." | grep -c "at dot\.junit\."` 243 if [[ $stacktraces > 0 ]]; then 244 jtype=`echo "$mainclass" | sed -e 's/.*_test\([^0-9]*\)[0-9].*/\1/' ` 245 if [ "$jtype" == "VFE" ]; then 246 (( jvfefailedcnt += 1 )) 247 echo -n "V" 248 else 249 (( jfailedcnt += 1 )) 250 echo -n "F" 251 fi 252 253 echo "<tr class=\"nok\"><td>Failure</td><td>$jtitle</td><td>" >> $report 254 echo "$jcomment</td><td>$vmres</td></tr>" >> $report 255 else 256 (( jwarningcnt += 1 )) 257 echo "<tr class=\"wok\"><td>Failure</td><td>$jtitle</td><td>" >> $report 258 echo "$jcomment</td><td>(No stacktrace, but errors on console)" >> $report 259 echo "<br>$vmres</td></tr>" >> $report 260 echo -n "C" 261 fi 262 fi 263 264 (( jcolumns += 1 )) 265 if [ ${jcolumns} -eq 40 ]; then 266 echo "" 267 (( jcolumns = 0 )) 268 fi 269 270 fi 271 # Use fd nr 3 to avoid subshelling via cat since this looses all 272 # variables(and thus also the counters we are interested in). 273 done 3<$scriptdata 274 275 echo "</table>" >> $report 276 let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt 277 if [ $jallcalccnt -ne $jallcnt ]; then 278 echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report 279 exit 1; 280 fi 281 282 echo $post_report >> $report 283 284 echo "<br>Tests run: ${jallcnt}" >> $report 285 echo "<br>Functional failures: ${jfailedcnt}" >> $report 286 echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report 287 echo "<br>Console errors: ${jwarningcnt}" >> $report 288 289 echo $post_report >> $report 290 291 if [[ jcolumns -ne 0 ]]; then 292 echo "" 293 fi 294 295 echo "" 296 297 if [[ jallcnt -eq jpassedcnt ]]; then 298 echo "OK (${jpassedcnt} tests)" 299 else 300 echo "FAILURES!!!" 301 echo "" 302 echo "Tests run : ${jallcnt}" 303 echo "Functional failures: ${jfailedcnt}" 304 echo "Verifier failures : ${jvfefailedcnt}" 305 echo "Console errors : ${jwarningcnt}" 306 fi 307 308 echo "" 309 echo "Please see complete report in ${report}" 310 echo "--------------------------------------------------" 311