blob: 735549e4d8aa4d518cdb1fce10ec1b964bda9aba [file] [log] [blame]
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +00001#!/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
Colin Crosse0ef0a82017-07-27 21:29:18 +000022source build/envsetup.sh >&/dev/null # for get_build_var, setpaths
23setpaths # include platform prebuilt java, javac, etc in $PATH.
Shubham Ajmerac33c0872017-07-20 18:41:52 -070024
Andreas Gampeebd089d2016-07-18 14:56:56 -070025if [ -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
Roland Levillain08f7c1d2018-05-25 15:34:41 +010031# "Root" (actually "system") directory on device (in the case of
32# target testing).
33android_root=${ART_TEST_ANDROID_ROOT:-/system}
Roland Levillain1c361882018-03-02 14:23:51 +000034
Igor Murashkin84f26322017-06-06 11:36:33 -070035function classes_jar_path {
36 local var="$1"
37 local suffix="jar"
38
Igor Murashkin84f26322017-06-06 11:36:33 -070039 echo "${JAVA_LIBRARIES}/${var}_intermediates/classes.${suffix}"
40}
41
Tobias Thiererb3ec0892016-08-03 16:13:04 +010042function cparg {
43 for var
44 do
Igor Murashkin84f26322017-06-06 11:36:33 -070045 printf -- "--classpath $(classes_jar_path "$var") ";
Tobias Thiererb3ec0892016-08-03 16:13:04 +010046 done
47}
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +010048
Vladimir Marko91f10322018-12-07 18:04:10 +000049function 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
Vladimir Marko0ace5632018-12-14 11:11:47 +000060# Note: This must start with the CORE_IMG_JARS in Android.common_path.mk
Vladimir Marko91f10322018-12-07 18:04:10 +000061# because that's what we use for compiling the core.art image.
Vladimir Marko0ace5632018-12-14 11:11:47 +000062# It may contain additional modules from TEST_CORE_JARS.
Neil Fullerb4a70ce2018-11-09 15:49:05 +000063BOOT_CLASSPATH_JARS="core-oj core-libart okhttp bouncycastle apache-xml conscrypt"
Vladimir Marko91f10322018-12-07 18:04:10 +000064
Tobias Thiererb3ec0892016-08-03 16:13:04 +010065DEPS="core-tests jsr166-tests mockito-target"
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +010066
Tobias Thiererb3ec0892016-08-03 16:13:04 +010067for lib in $DEPS
68do
Igor Murashkin84f26322017-06-06 11:36:33 -070069 if [[ ! -f "$(classes_jar_path "$lib")" ]]; then
Tobias Thiererb3ec0892016-08-03 16:13:04 +010070 echo "${lib} is missing. Before running, you must run art/tools/buildbot-build.sh"
71 exit 1
72 fi
73done
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +000074
Roland Levillainafd6f9e2016-01-11 15:51:00 +000075expectations="--expectations art/tools/libcore_failures.txt"
Roland Levillainafd6f9e2016-01-11 15:51:00 +000076
Nicolas Geoffrayf794ad72015-09-11 12:08:49 +010077emulator="no"
78if [ "$ANDROID_SERIAL" = "emulator-5554" ]; then
79 emulator="yes"
80fi
81
Roland Levillain5db109b2016-05-19 12:24:17 +010082# Use JIT compiling by default.
83use_jit=true
84
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +000085# Packages that currently work correctly with the expectation files.
Andreas Gampee1661362017-11-08 16:42:14 -080086working_packages=("libcore.dalvik.system"
David Brazdil598b2202015-02-24 10:12:06 +000087 "libcore.java.lang"
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +000088 "libcore.java.math"
David Brazdil598b2202015-02-24 10:12:06 +000089 "libcore.java.text"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000090 "libcore.java.util"
David Brazdil4cd7dfd2015-02-24 13:33:01 +000091 "libcore.javax.crypto"
David Brazdil598b2202015-02-24 10:12:06 +000092 "libcore.javax.security"
93 "libcore.javax.sql"
94 "libcore.javax.xml"
Andreas Gampee1661362017-11-08 16:42:14 -080095 "libcore.libcore.io"
96 "libcore.libcore.net"
97 "libcore.libcore.reflect"
98 "libcore.libcore.util"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000099 "org.apache.harmony.annotation"
David Brazdil4cd7dfd2015-02-24 13:33:01 +0000100 "org.apache.harmony.crypto"
David Brazdile2f28ad2015-02-24 10:44:29 +0000101 "org.apache.harmony.luni"
102 "org.apache.harmony.nio"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +0000103 "org.apache.harmony.regex"
David Brazdile2f28ad2015-02-24 10:44:29 +0000104 "org.apache.harmony.testframework"
105 "org.apache.harmony.tests.java.io"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +0000106 "org.apache.harmony.tests.java.lang"
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +0000107 "org.apache.harmony.tests.java.math"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +0000108 "org.apache.harmony.tests.java.util"
David Brazdile2f28ad2015-02-24 10:44:29 +0000109 "org.apache.harmony.tests.java.text"
110 "org.apache.harmony.tests.javax.security"
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +0100111 "tests.java.lang.String"
112 "jsr166")
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +0000113
Nicolas Geoffraycdcd0002015-10-31 14:47:36 +0000114# 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
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100118vogar_args=$@
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100119gcstress=false
120debug=false
121
Roland Levillaine4f1c512017-10-30 13:28:28 +0000122# Don't use device mode by default.
123device_mode=false
Roland Levillaine4f1c512017-10-30 13:28:28 +0000124
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100125while true; do
126 if [[ "$1" == "--mode=device" ]]; then
Roland Levillaine4f1c512017-10-30 13:28:28 +0000127 device_mode=true
Nicolas Geoffray191cae32019-01-09 09:36:03 +0000128 # 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"
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +0000131 vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art"
Vladimir Marko91f10322018-12-07 18:04:10 +0000132 vogar_args="$vogar_args $(boot_classpath_arg /system/framework -testdex $BOOT_CLASSPATH_JARS)"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100133 shift
134 elif [[ "$1" == "--mode=host" ]]; then
Andreas Gampe8994a042015-12-30 19:03:17 +0000135 # 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"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100140 shift
Roland Levillain5db109b2016-05-19 12:24:17 +0100141 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
Nicolas Geoffray7f437912015-06-15 14:35:01 +0100146 elif [[ "$1" == "--debug" ]]; then
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100147 # Remove the --debug from the arguments.
148 vogar_args=${vogar_args/$1}
Andreas Gampe1c5b42f2017-06-15 18:20:45 -0700149 vogar_args="$vogar_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true"
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100150 debug=true
151 shift
152 elif [[ "$1" == "-Xgc:gcstress" ]]; then
153 gcstress=true
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100154 shift
155 elif [[ "$1" == "" ]]; then
156 break
157 else
158 shift
159 fi
160done
161
Roland Levillaine4f1c512017-10-30 13:28:28 +0000162if $device_mode; then
Roland Levillain08f7c1d2018-05-25 15:34:41 +0100163 # 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"
Roland Levillaine4f1c512017-10-30 13:28:28 +0000167 vogar_args="$vogar_args --device-dir=/tmp"
Roland Levillaine4f1c512017-10-30 13:28:28 +0000168 else
Roland Levillain08f7c1d2018-05-25 15:34:41 +0100169 # When not using a chroot on device, set Vogar's work directory to
170 # /data/local/tmp.
Roland Levillaine4f1c512017-10-30 13:28:28 +0000171 vogar_args="$vogar_args --device-dir=/data/local/tmp"
Roland Levillaine4f1c512017-10-30 13:28:28 +0000172 fi
Roland Levillain08f7c1d2018-05-25 15:34:41 +0100173 vogar_args="$vogar_args --vm-command=$android_root/bin/art"
Roland Levillaine4f1c512017-10-30 13:28:28 +0000174fi
175
Nicolas Geoffray44368e82015-09-30 12:02:21 +0100176# 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.
Nicolas Geoffraya353ce52018-08-06 09:28:20 +0100179if $gcstress && $debug && $device_mode; then
Nicolas Geoffray793bed32018-08-22 15:07:40 +0100180 vogar_args="$vogar_args --timeout 1440"
Nicolas Geoffraya353ce52018-08-06 09:28:20 +0100181else
182 vogar_args="$vogar_args --timeout 480"
183fi
Nicolas Geoffrayf794ad72015-09-11 12:08:49 +0100184
Neil Fuller239bdf62018-01-08 18:55:36 +0000185# set the toolchain to use.
186vogar_args="$vogar_args --toolchain d8 --language CUR"
Neil Fullerb8300fc2016-02-10 13:09:10 +0000187
Roland Levillain5db109b2016-05-19 12:24:17 +0100188# JIT settings.
189if $use_jit; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100190 vogar_args="$vogar_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken"
Roland Levillain5db109b2016-05-19 12:24:17 +0100191fi
192vogar_args="$vogar_args --vm-arg -Xusejit:$use_jit"
193
Nicolas Geoffray5b455d32017-07-05 10:51:06 +0100194# gcstress may lead to timeouts, so we need dedicated expectations files for it.
Nicolas Geoffraya6555752018-05-02 10:39:09 +0100195if $gcstress; then
Nicolas Geoffray5b455d32017-07-05 10:51:06 +0100196 expectations="$expectations --expectations art/tools/libcore_gcstress_failures.txt"
Nicolas Geoffraya6555752018-05-02 10:39:09 +0100197 if $debug; then
Nicolas Geoffray5b455d32017-07-05 10:51:06 +0100198 expectations="$expectations --expectations art/tools/libcore_gcstress_debug_failures.txt"
199 fi
Nicolas Geoffraya6555752018-05-02 10:39:09 +0100200else
201 # We only run this package when not under gcstress as it can cause timeouts. See b/78228743.
202 working_packages+=("libcore.libcore.icu")
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100203fi
204
Roland Levillain3840b342018-03-29 19:36:12 +0100205# 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
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +0000215# Run the tests using vogar.
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +0000216echo "Running tests for the following test packages:"
217echo ${working_packages[@]} | tr " " "\n"
Nicolas Geoffray793bed32018-08-22 15:07:40 +0100218
219cmd="vogar $vogar_args $expectations $(cparg $DEPS) ${working_packages[@]}"
220echo "Running $cmd"
221eval $cmd