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 17if [ ! -d libcore ]; then 18 echo "Script needs to be run at the root of the android tree" 19 exit 1 20fi 21 22source build/envsetup.sh >&/dev/null # for get_build_var, setpaths 23setpaths # include platform prebuilt java, javac, etc in $PATH. 24 25if [ -z "$ANDROID_PRODUCT_OUT" ] ; then 26 JAVA_LIBRARIES=out/target/common/obj/JAVA_LIBRARIES 27else 28 JAVA_LIBRARIES=${ANDROID_PRODUCT_OUT}/../../common/obj/JAVA_LIBRARIES 29fi 30 31# "Root" (actually "system") directory on device (in the case of 32# target testing). 33android_root=${ART_TEST_ANDROID_ROOT:-/system} 34 35function classes_jar_path { 36 local var="$1" 37 local suffix="jar" 38 39 echo "${JAVA_LIBRARIES}/${var}_intermediates/classes.${suffix}" 40} 41 42function cparg { 43 for var 44 do 45 printf -- "--classpath $(classes_jar_path "$var") "; 46 done 47} 48 49function boot_classpath_arg { 50 local dir="$1" 51 local suffix="$2" 52 shift 2 53 printf -- "--vm-arg -Xbootclasspath" 54 for var 55 do 56 printf -- ":${dir}/${var}${suffix}.jar"; 57 done 58} 59 60# Note: This must start with the CORE_IMG_JARS in Android.common_path.mk 61# because that's what we use for compiling the core.art image. 62# It may contain additional modules from TEST_CORE_JARS. 63BOOT_CLASSPATH_JARS="core-oj core-libart okhttp bouncycastle apache-xml conscrypt" 64 65DEPS="core-tests jsr166-tests mockito-target" 66 67for lib in $DEPS 68do 69 if [[ ! -f "$(classes_jar_path "$lib")" ]]; then 70 echo "${lib} is missing. Before running, you must run art/tools/buildbot-build.sh" 71 exit 1 72 fi 73done 74 75expectations="--expectations art/tools/libcore_failures.txt" 76 77emulator="no" 78if [ "$ANDROID_SERIAL" = "emulator-5554" ]; then 79 emulator="yes" 80fi 81 82# Use JIT compiling by default. 83use_jit=true 84 85# Packages that currently work correctly with the expectation files. 86working_packages=("libcore.dalvik.system" 87 "libcore.java.lang" 88 "libcore.java.math" 89 "libcore.java.text" 90 "libcore.java.util" 91 "libcore.javax.crypto" 92 "libcore.javax.security" 93 "libcore.javax.sql" 94 "libcore.javax.xml" 95 "libcore.libcore.io" 96 "libcore.libcore.net" 97 "libcore.libcore.reflect" 98 "libcore.libcore.util" 99 "org.apache.harmony.annotation" 100 "org.apache.harmony.crypto" 101 "org.apache.harmony.luni" 102 "org.apache.harmony.nio" 103 "org.apache.harmony.regex" 104 "org.apache.harmony.testframework" 105 "org.apache.harmony.tests.java.io" 106 "org.apache.harmony.tests.java.lang" 107 "org.apache.harmony.tests.java.math" 108 "org.apache.harmony.tests.java.util" 109 "org.apache.harmony.tests.java.text" 110 "org.apache.harmony.tests.javax.security" 111 "tests.java.lang.String" 112 "jsr166") 113 114# List of packages we could run, but don't have rights to revert 115# changes in case of failures. 116# "org.apache.harmony.security" 117 118vogar_args=$@ 119gcstress=false 120debug=false 121 122# Don't use device mode by default. 123device_mode=false 124 125while true; do 126 if [[ "$1" == "--mode=device" ]]; then 127 device_mode=true 128 # Remove the --mode=device from the arguments and replace it with --mode=device_testdex 129 vogar_args=${vogar_args/$1} 130 vogar_args="$vogar_args --mode=device_testdex" 131 vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art" 132 vogar_args="$vogar_args $(boot_classpath_arg /system/framework -testdex $BOOT_CLASSPATH_JARS)" 133 shift 134 elif [[ "$1" == "--mode=host" ]]; then 135 # We explicitly give a wrong path for the image, to ensure vogar 136 # will create a boot image with the default compiler. Note that 137 # giving an existing image on host does not work because of 138 # classpath/resources differences when compiling the boot image. 139 vogar_args="$vogar_args --vm-arg -Ximage:/non/existent/vogar.art" 140 shift 141 elif [[ "$1" == "--no-jit" ]]; then 142 # Remove the --no-jit from the arguments. 143 vogar_args=${vogar_args/$1} 144 use_jit=false 145 shift 146 elif [[ "$1" == "--debug" ]]; then 147 # Remove the --debug from the arguments. 148 vogar_args=${vogar_args/$1} 149 vogar_args="$vogar_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true" 150 debug=true 151 shift 152 elif [[ "$1" == "-Xgc:gcstress" ]]; then 153 gcstress=true 154 shift 155 elif [[ "$1" == "" ]]; then 156 break 157 else 158 shift 159 fi 160done 161 162if $device_mode; then 163 # Honor environment variable ART_TEST_CHROOT. 164 if [[ -n "$ART_TEST_CHROOT" ]]; then 165 # Set Vogar's `--chroot` option. 166 vogar_args="$vogar_args --chroot $ART_TEST_CHROOT" 167 vogar_args="$vogar_args --device-dir=/tmp" 168 else 169 # When not using a chroot on device, set Vogar's work directory to 170 # /data/local/tmp. 171 vogar_args="$vogar_args --device-dir=/data/local/tmp" 172 fi 173 vogar_args="$vogar_args --vm-command=$android_root/bin/art" 174fi 175 176# Increase the timeout, as vogar cannot set individual test 177# timeout when being asked to run packages, and some tests go above 178# the default timeout. 179if $gcstress && $debug && $device_mode; then 180 vogar_args="$vogar_args --timeout 1440" 181else 182 vogar_args="$vogar_args --timeout 480" 183fi 184 185# set the toolchain to use. 186vogar_args="$vogar_args --toolchain d8 --language CUR" 187 188# JIT settings. 189if $use_jit; then 190 vogar_args="$vogar_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken" 191fi 192vogar_args="$vogar_args --vm-arg -Xusejit:$use_jit" 193 194# gcstress may lead to timeouts, so we need dedicated expectations files for it. 195if $gcstress; then 196 expectations="$expectations --expectations art/tools/libcore_gcstress_failures.txt" 197 if $debug; then 198 expectations="$expectations --expectations art/tools/libcore_gcstress_debug_failures.txt" 199 fi 200else 201 # We only run this package when not under gcstress as it can cause timeouts. See b/78228743. 202 working_packages+=("libcore.libcore.icu") 203fi 204 205# Disable network-related libcore tests that are failing on the following 206# devices running Android O, as a workaround for b/74725685: 207# - FA7BN1A04406 (walleye device testing configuration aosp-poison/volantis-armv7-poison-debug) 208# - FA7BN1A04412 (walleye device testing configuration aosp-poison/volantis-armv8-poison-ndebug) 209# - FA7BN1A04433 (walleye device testing configuration aosp-poison/volantis-armv8-poison-debug) 210case "$ANDROID_SERIAL" in 211 (FA7BN1A04406|FA7BN1A04412|FA7BN1A04433) 212 expectations="$expectations --expectations art/tools/libcore_network_failures.txt";; 213esac 214 215# Run the tests using vogar. 216echo "Running tests for the following test packages:" 217echo ${working_packages[@]} | tr " " "\n" 218 219cmd="vogar $vogar_args $expectations $(cparg $DEPS) ${working_packages[@]}" 220echo "Running $cmd" 221eval $cmd 222