Andreas Gampe | 481ef20 | 2017-08-25 17:08:32 -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 | javaOpts="" |
| 39 | while expr "x$1" : 'x-J' >/dev/null; do |
| 40 | opt=`expr "$1" : '-J\(.*\)'` |
| 41 | javaOpts="${javaOpts} -${opt}" |
| 42 | shift |
| 43 | done |
| 44 | |
| 45 | |
| 46 | ####################################################################### |
| 47 | # Original content of invocation script follows. Uses values cleverly |
| 48 | # deduced by the above code. |
| 49 | ####################################################################### |
| 50 | |
| 51 | selection=$1 |
| 52 | interpreter="fast" |
| 53 | if [ "$selection" = "--portable" ]; then |
| 54 | selection=$2; |
| 55 | interpreter="portable" |
| 56 | fi |
| 57 | |
| 58 | dalviktest=$ANDROID_BUILD_TOP/out/host/common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates |
| 59 | dalviktestdir=$dalviktest/tests |
| 60 | dexcore=$dalviktest/tests/dot/junit/dexcore.jar |
| 61 | scriptdata=$dalviktestdir/data/scriptdata |
| 62 | report=$dalviktest/report.html |
| 63 | curdate=`date` |
| 64 | datadir=/tmp/${USER} |
| 65 | export ANDROID_PRINTF_LOG=tag |
| 66 | export ANDROID_LOG_TAGS='*:s' # was: jdwp:i dalvikvm:i dalvikvmi:i' |
| 67 | export ANDROID_DATA=$datadir |
| 68 | export ANDROID_ROOT=$ANDROID_HOST_OUT |
| 69 | # export LD_LIBRARY_PATH=$base/system/lib |
| 70 | # export DYLD_LIBRARY_PATH=$base/system/lib |
| 71 | debug_opts="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" |
| 72 | vmtpath=$ANDROID_HOST_OUT/../common/obj/JAVA_LIBRARIES/vm-tests-tf_intermediates/tests |
| 73 | |
| 74 | echo "--------------------------------------------------" |
| 75 | echo "Dalvik VM Test Suite" |
| 76 | echo "Version 1.0" |
| 77 | echo "Copyright (c) 2008 The Android Open Source Project" |
| 78 | echo "" |
| 79 | |
| 80 | if [ "$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; |
| 89 | fi |
| 90 | |
| 91 | rm -rf --preserve-root $datadir/dalvik-cache |
| 92 | mkdir -p $datadir |
| 93 | mkdir -p $datadir/dalvik-cache |
| 94 | |
| 95 | echo "" |
| 96 | |
| 97 | pre_report="<html><head><style> |
| 98 | table tr.ok { background:#a0ffa0; } |
| 99 | table tr.nok { background:#ffa0a0; } |
| 100 | table tr.wok { background:#ffffa0; } |
| 101 | table tr.lok { background:#aaaaff; } |
| 102 | </style></head> |
| 103 | <body> |
| 104 | <h1>Dalvik VM test suite results</h1> |
| 105 | Generated $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>" |
| 109 | post_report="</body></html>" |
| 110 | |
| 111 | rm -f $report |
| 112 | echo $pre_report > $report |
| 113 | |
| 114 | # ----------- running each opcode test ------------ |
| 115 | |
| 116 | export jpassedcnt=0 |
| 117 | export jfailedcnt=0 |
| 118 | export jvfefailedcnt=0 |
| 119 | export jwarningcnt=0 |
| 120 | export jallcnt=0 |
| 121 | export jcolumns=0 |
| 122 | |
| 123 | function classnameToJar() |
| 124 | { |
| 125 | echo $1 | sed -e 's#\.#/#g;s#$#.jar#' |
| 126 | } |
| 127 | |
| 128 | while read -u 3 myline; |
| 129 | do |
| 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). |
| 212 | done 3<$scriptdata |
| 213 | |
| 214 | echo "</table>" >> $report |
| 215 | let jallcalccnt=$jpassedcnt+$jfailedcnt+$jvfefailedcnt+$jwarningcnt |
| 216 | if [ $jallcalccnt -ne $jallcnt ]; then |
| 217 | echo "<br>error: green & red != total , $jallcalccnt -ne $jallcnt" >> $report |
| 218 | exit 1; |
| 219 | fi |
| 220 | |
| 221 | echo $post_report >> $report |
| 222 | |
| 223 | echo "<br>Tests run: ${jallcnt}" >> $report |
| 224 | echo "<br>Functional failures: ${jfailedcnt}" >> $report |
| 225 | echo "<br>Verifier failures: ${jvfefailedcnt}" >> $report |
| 226 | echo "<br>Console errors: ${jwarningcnt}" >> $report |
| 227 | |
| 228 | echo $post_report >> $report |
| 229 | |
| 230 | if [[ jcolumns -ne 0 ]]; then |
| 231 | echo "" |
| 232 | fi |
| 233 | |
| 234 | echo "" |
| 235 | |
| 236 | if [[ jallcnt -eq jpassedcnt ]]; then |
| 237 | echo "OK (${jpassedcnt} tests)" |
| 238 | else |
| 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}" |
| 245 | fi |
| 246 | |
| 247 | echo "" |
| 248 | echo "Please see complete report in ${report}" |
| 249 | echo "--------------------------------------------------" |