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