blob: eecdd2fb5e653fd2a597516e7098201be2288343 [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
Igor Murashkin08e33972017-07-26 13:03:00 -070022source 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
Igor Murashkin08e33972017-07-26 13:03:00 -070031using_jack=$(get_build_var ANDROID_COMPILE_WITH_JACK)
Igor Murashkin84f26322017-06-06 11:36:33 -070032
33function classes_jar_path {
34 local var="$1"
35 local suffix="jar"
36
Igor Murashkin08e33972017-07-26 13:03:00 -070037 if [[ $using_jack == "true" ]]; then
Igor Murashkin84f26322017-06-06 11:36:33 -070038 suffix="jack"
39 fi
40
41 echo "${JAVA_LIBRARIES}/${var}_intermediates/classes.${suffix}"
42}
43
Tobias Thiererb3ec0892016-08-03 16:13:04 +010044function cparg {
45 for var
46 do
Igor Murashkin84f26322017-06-06 11:36:33 -070047 printf -- "--classpath $(classes_jar_path "$var") ";
Tobias Thiererb3ec0892016-08-03 16:13:04 +010048 done
49}
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +010050
Tobias Thiererb3ec0892016-08-03 16:13:04 +010051DEPS="core-tests jsr166-tests mockito-target"
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +010052
Tobias Thiererb3ec0892016-08-03 16:13:04 +010053for lib in $DEPS
54do
Igor Murashkin84f26322017-06-06 11:36:33 -070055 if [[ ! -f "$(classes_jar_path "$lib")" ]]; then
Tobias Thiererb3ec0892016-08-03 16:13:04 +010056 echo "${lib} is missing. Before running, you must run art/tools/buildbot-build.sh"
57 exit 1
58 fi
59done
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +000060
Roland Levillainafd6f9e2016-01-11 15:51:00 +000061expectations="--expectations art/tools/libcore_failures.txt"
Roland Levillainafd6f9e2016-01-11 15:51:00 +000062
Nicolas Geoffrayf794ad72015-09-11 12:08:49 +010063emulator="no"
64if [ "$ANDROID_SERIAL" = "emulator-5554" ]; then
65 emulator="yes"
66fi
67
Roland Levillain5db109b2016-05-19 12:24:17 +010068# Use JIT compiling by default.
69use_jit=true
70
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +000071# Packages that currently work correctly with the expectation files.
Nicolas Geoffray1f8dbf82015-06-13 13:19:16 +000072working_packages=("dalvik.system"
Brian Carlstrom4c78ffa2015-06-11 07:33:51 -070073 "libcore.icu"
David Brazdil598b2202015-02-24 10:12:06 +000074 "libcore.io"
75 "libcore.java.lang"
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +000076 "libcore.java.math"
David Brazdil598b2202015-02-24 10:12:06 +000077 "libcore.java.text"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000078 "libcore.java.util"
David Brazdil4cd7dfd2015-02-24 13:33:01 +000079 "libcore.javax.crypto"
David Brazdil598b2202015-02-24 10:12:06 +000080 "libcore.javax.security"
81 "libcore.javax.sql"
82 "libcore.javax.xml"
83 "libcore.net"
84 "libcore.reflect"
85 "libcore.util"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000086 "org.apache.harmony.annotation"
David Brazdil4cd7dfd2015-02-24 13:33:01 +000087 "org.apache.harmony.crypto"
David Brazdile2f28ad2015-02-24 10:44:29 +000088 "org.apache.harmony.luni"
89 "org.apache.harmony.nio"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000090 "org.apache.harmony.regex"
David Brazdile2f28ad2015-02-24 10:44:29 +000091 "org.apache.harmony.testframework"
92 "org.apache.harmony.tests.java.io"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000093 "org.apache.harmony.tests.java.lang"
Nicolas Geoffrayc3837e42014-12-03 11:30:26 +000094 "org.apache.harmony.tests.java.math"
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +000095 "org.apache.harmony.tests.java.util"
David Brazdile2f28ad2015-02-24 10:44:29 +000096 "org.apache.harmony.tests.java.text"
97 "org.apache.harmony.tests.javax.security"
Wojciech Staszkiewicz08cf1482015-05-21 17:31:38 +010098 "tests.java.lang.String"
99 "jsr166")
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +0000100
Nicolas Geoffraycdcd0002015-10-31 14:47:36 +0000101# 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
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100105vogar_args=$@
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100106gcstress=false
107debug=false
108
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100109while 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"
Nicolas Geoffrayb76bc782016-09-14 12:33:34 +0000113 vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100114 shift
115 elif [[ "$1" == "--mode=host" ]]; then
Andreas Gampe8994a042015-12-30 19:03:17 +0000116 # 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"
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100121 shift
Roland Levillain5db109b2016-05-19 12:24:17 +0100122 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
Nicolas Geoffray7f437912015-06-15 14:35:01 +0100127 elif [[ "$1" == "--debug" ]]; then
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100128 # Remove the --debug from the arguments.
129 vogar_args=${vogar_args/$1}
Andreas Gampe1c5b42f2017-06-15 18:20:45 -0700130 vogar_args="$vogar_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true"
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100131 debug=true
132 shift
133 elif [[ "$1" == "-Xgc:gcstress" ]]; then
134 gcstress=true
Nicolas Geoffray9648a632015-06-15 14:35:01 +0100135 shift
136 elif [[ "$1" == "" ]]; then
137 break
138 else
139 shift
140 fi
141done
142
Nicolas Geoffray44368e82015-09-30 12:02:21 +0100143# 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.
146vogar_args="$vogar_args --timeout 480"
Nicolas Geoffrayf794ad72015-09-11 12:08:49 +0100147
Igor Murashkin84f26322017-06-06 11:36:33 -0700148# Switch between using jack or javac+desugar+dx
Igor Murashkin08e33972017-07-26 13:03:00 -0700149if [[ $using_jack == "true" ]]; then
Igor Murashkin84f26322017-06-06 11:36:33 -0700150 vogar_args="$vogar_args --toolchain jack --language JO"
151else
152 vogar_args="$vogar_args --toolchain jdk --language CUR"
153fi
Neil Fullerb8300fc2016-02-10 13:09:10 +0000154
Roland Levillain5db109b2016-05-19 12:24:17 +0100155# JIT settings.
156if $use_jit; then
Nicolas Geoffray49cda062017-04-21 13:08:25 +0100157 vogar_args="$vogar_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken"
Roland Levillain5db109b2016-05-19 12:24:17 +0100158fi
159vogar_args="$vogar_args --vm-arg -Xusejit:$use_jit"
160
Nicolas Geoffray5b455d32017-07-05 10:51:06 +0100161# gcstress may lead to timeouts, so we need dedicated expectations files for it.
162if [[ $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
Nicolas Geoffray622e2e22017-06-15 09:33:01 +0100167fi
168
Nicolas Geoffrayb2e7e242014-11-28 14:24:28 +0000169# Run the tests using vogar.
Nicolas Geoffray3cdf8182014-12-01 10:12:15 +0000170echo "Running tests for the following test packages:"
171echo ${working_packages[@]} | tr " " "\n"
Tobias Thiererb3ec0892016-08-03 16:13:04 +0100172vogar $vogar_args $expectations $(cparg $DEPS) ${working_packages[@]}