Home | History | Annotate | Download | only in tools
      1 #!/bin/bash
      2 #
      3 # Copyright (C) 2014 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 if [ ! -d libcore ]; then
     18   echo "Script needs to be run at the root of the android tree"
     19   exit 1
     20 fi
     21 
     22 if [ -z "$ANDROID_PRODUCT_OUT" ] ; then
     23   JAVA_LIBRARIES=out/target/common/obj/JAVA_LIBRARIES
     24 else
     25   JAVA_LIBRARIES=${ANDROID_PRODUCT_OUT}/../../common/obj/JAVA_LIBRARIES
     26 fi
     27 
     28 using_jack=true
     29 if [[ $ANDROID_COMPILE_WITH_JACK == false ]]; then
     30   using_jack=false
     31 fi
     32 
     33 function classes_jar_path {
     34   local var="$1"
     35   local suffix="jar"
     36 
     37   if $using_jack; then
     38     suffix="jack"
     39   fi
     40 
     41   echo "${JAVA_LIBRARIES}/${var}_intermediates/classes.${suffix}"
     42 }
     43 
     44 function cparg {
     45   for var
     46   do
     47     printf -- "--classpath $(classes_jar_path "$var") ";
     48   done
     49 }
     50 
     51 DEPS="core-tests jsr166-tests mockito-target"
     52 
     53 for lib in $DEPS
     54 do
     55   if [[ ! -f "$(classes_jar_path "$lib")" ]]; then
     56     echo "${lib} is missing. Before running, you must run art/tools/buildbot-build.sh"
     57     exit 1
     58   fi
     59 done
     60 
     61 expectations="--expectations art/tools/libcore_failures.txt"
     62 
     63 emulator="no"
     64 if [ "$ANDROID_SERIAL" = "emulator-5554" ]; then
     65   emulator="yes"
     66 fi
     67 
     68 # Use JIT compiling by default.
     69 use_jit=true
     70 
     71 # Packages that currently work correctly with the expectation files.
     72 working_packages=("dalvik.system"
     73                   "libcore.icu"
     74                   "libcore.io"
     75                   "libcore.java.lang"
     76                   "libcore.java.math"
     77                   "libcore.java.text"
     78                   "libcore.java.util"
     79                   "libcore.javax.crypto"
     80                   "libcore.javax.security"
     81                   "libcore.javax.sql"
     82                   "libcore.javax.xml"
     83                   "libcore.net"
     84                   "libcore.reflect"
     85                   "libcore.util"
     86                   "org.apache.harmony.annotation"
     87                   "org.apache.harmony.crypto"
     88                   "org.apache.harmony.luni"
     89                   "org.apache.harmony.nio"
     90                   "org.apache.harmony.regex"
     91                   "org.apache.harmony.testframework"
     92                   "org.apache.harmony.tests.java.io"
     93                   "org.apache.harmony.tests.java.lang"
     94                   "org.apache.harmony.tests.java.math"
     95                   "org.apache.harmony.tests.java.util"
     96                   "org.apache.harmony.tests.java.text"
     97                   "org.apache.harmony.tests.javax.security"
     98                   "tests.java.lang.String"
     99                   "jsr166")
    100 
    101 # List of packages we could run, but don't have rights to revert
    102 # changes in case of failures.
    103 # "org.apache.harmony.security"
    104 
    105 vogar_args=$@
    106 gcstress=false
    107 debug=false
    108 
    109 while true; do
    110   if [[ "$1" == "--mode=device" ]]; then
    111     vogar_args="$vogar_args --device-dir=/data/local/tmp"
    112     vogar_args="$vogar_args --vm-command=/data/local/tmp/system/bin/art"
    113     vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art"
    114     shift
    115   elif [[ "$1" == "--mode=host" ]]; then
    116     # We explicitly give a wrong path for the image, to ensure vogar
    117     # will create a boot image with the default compiler. Note that
    118     # giving an existing image on host does not work because of
    119     # classpath/resources differences when compiling the boot image.
    120     vogar_args="$vogar_args --vm-arg -Ximage:/non/existent/vogar.art"
    121     shift
    122   elif [[ "$1" == "--no-jit" ]]; then
    123     # Remove the --no-jit from the arguments.
    124     vogar_args=${vogar_args/$1}
    125     use_jit=false
    126     shift
    127   elif [[ "$1" == "--debug" ]]; then
    128     # Remove the --debug from the arguments.
    129     vogar_args=${vogar_args/$1}
    130     vogar_args="$vogar_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true"
    131     debug=true
    132     shift
    133   elif [[ "$1" == "-Xgc:gcstress" ]]; then
    134     gcstress=true
    135     shift
    136   elif [[ "$1" == "" ]]; then
    137     break
    138   else
    139     shift
    140   fi
    141 done
    142 
    143 # Increase the timeout, as vogar cannot set individual test
    144 # timeout when being asked to run packages, and some tests go above
    145 # the default timeout.
    146 vogar_args="$vogar_args --timeout 480"
    147 
    148 # Switch between using jack or javac+desugar+dx
    149 if $using_jack; then
    150   vogar_args="$vogar_args --toolchain jack --language JO"
    151 else
    152   vogar_args="$vogar_args --toolchain jdk --language CUR"
    153 fi
    154 
    155 # JIT settings.
    156 if $use_jit; then
    157   vogar_args="$vogar_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken"
    158 fi
    159 vogar_args="$vogar_args --vm-arg -Xusejit:$use_jit"
    160 
    161 # gcstress may lead to timeouts, so we need dedicated expectations files for it.
    162 if [[ $gcstress ]]; then
    163   expectations="$expectations --expectations art/tools/libcore_gcstress_failures.txt"
    164   if [[ $debug ]]; then
    165     expectations="$expectations --expectations art/tools/libcore_gcstress_debug_failures.txt"
    166   fi
    167 fi
    168 
    169 # Run the tests using vogar.
    170 echo "Running tests for the following test packages:"
    171 echo ${working_packages[@]} | tr " " "\n"
    172 vogar $vogar_args $expectations $(cparg $DEPS) ${working_packages[@]}
    173