Nicolas Geoffray | b2e7e24 | 2014-11-28 14:24:28 +0000 | [diff] [blame] | 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 | |
Colin Cross | e0ef0a8 | 2017-07-27 21:29:18 +0000 | [diff] [blame] | 22 | source build/envsetup.sh >&/dev/null # for get_build_var, setpaths |
| 23 | setpaths # include platform prebuilt java, javac, etc in $PATH. |
Shubham Ajmera | c33c087 | 2017-07-20 18:41:52 -0700 | [diff] [blame] | 24 | |
Andreas Gampe | ebd089d | 2016-07-18 14:56:56 -0700 | [diff] [blame] | 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 | |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 31 | # "Root" (actually "system") directory on device (in the case of |
| 32 | # target testing). |
| 33 | android_root=${ART_TEST_ANDROID_ROOT:-/system} |
Roland Levillain | 1c36188 | 2018-03-02 14:23:51 +0000 | [diff] [blame] | 34 | |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 35 | function classes_jar_path { |
| 36 | local var="$1" |
| 37 | local suffix="jar" |
| 38 | |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 39 | echo "${JAVA_LIBRARIES}/${var}_intermediates/classes.${suffix}" |
| 40 | } |
| 41 | |
Tobias Thierer | b3ec089 | 2016-08-03 16:13:04 +0100 | [diff] [blame] | 42 | function cparg { |
| 43 | for var |
| 44 | do |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 45 | printf -- "--classpath $(classes_jar_path "$var") "; |
Tobias Thierer | b3ec089 | 2016-08-03 16:13:04 +0100 | [diff] [blame] | 46 | done |
| 47 | } |
Wojciech Staszkiewicz | 08cf148 | 2015-05-21 17:31:38 +0100 | [diff] [blame] | 48 | |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 49 | function 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 Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 60 | # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 61 | # because that's what we use for compiling the core.art image. |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 62 | # It may contain additional modules from TEST_CORE_JARS. |
Victor Chang | 759845f | 2019-08-06 16:04:36 +0100 | [diff] [blame] | 63 | BOOT_CLASSPATH_JARS="core-oj core-libart core-icu4j okhttp bouncycastle apache-xml conscrypt" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 64 | |
Tobias Thierer | b3ec089 | 2016-08-03 16:13:04 +0100 | [diff] [blame] | 65 | DEPS="core-tests jsr166-tests mockito-target" |
Wojciech Staszkiewicz | 08cf148 | 2015-05-21 17:31:38 +0100 | [diff] [blame] | 66 | |
Tobias Thierer | b3ec089 | 2016-08-03 16:13:04 +0100 | [diff] [blame] | 67 | for lib in $DEPS |
| 68 | do |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 69 | if [[ ! -f "$(classes_jar_path "$lib")" ]]; then |
Tobias Thierer | b3ec089 | 2016-08-03 16:13:04 +0100 | [diff] [blame] | 70 | echo "${lib} is missing. Before running, you must run art/tools/buildbot-build.sh" |
| 71 | exit 1 |
| 72 | fi |
| 73 | done |
Nicolas Geoffray | b2e7e24 | 2014-11-28 14:24:28 +0000 | [diff] [blame] | 74 | |
Roland Levillain | afd6f9e | 2016-01-11 15:51:00 +0000 | [diff] [blame] | 75 | expectations="--expectations art/tools/libcore_failures.txt" |
Roland Levillain | afd6f9e | 2016-01-11 15:51:00 +0000 | [diff] [blame] | 76 | |
Nicolas Geoffray | f794ad7 | 2015-09-11 12:08:49 +0100 | [diff] [blame] | 77 | emulator="no" |
| 78 | if [ "$ANDROID_SERIAL" = "emulator-5554" ]; then |
| 79 | emulator="yes" |
| 80 | fi |
| 81 | |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 82 | # Use JIT compiling by default. |
| 83 | use_jit=true |
| 84 | |
Nicolas Geoffray | c3837e4 | 2014-12-03 11:30:26 +0000 | [diff] [blame] | 85 | # Packages that currently work correctly with the expectation files. |
Roland Levillain | d2f8ce1 | 2019-06-19 17:50:32 +0100 | [diff] [blame] | 86 | working_packages=("libcore.android.system" |
Roland Levillain | 9e18907 | 2019-06-19 17:51:08 +0100 | [diff] [blame] | 87 | "libcore.build" |
Roland Levillain | d2f8ce1 | 2019-06-19 17:50:32 +0100 | [diff] [blame] | 88 | "libcore.dalvik.system" |
Roland Levillain | b06e0ad | 2019-06-19 19:07:57 +0100 | [diff] [blame] | 89 | "libcore.java.awt" |
David Brazdil | 598b220 | 2015-02-24 10:12:06 +0000 | [diff] [blame] | 90 | "libcore.java.lang" |
Nicolas Geoffray | c3837e4 | 2014-12-03 11:30:26 +0000 | [diff] [blame] | 91 | "libcore.java.math" |
David Brazdil | 598b220 | 2015-02-24 10:12:06 +0000 | [diff] [blame] | 92 | "libcore.java.text" |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 93 | "libcore.java.util" |
David Brazdil | 4cd7dfd | 2015-02-24 13:33:01 +0000 | [diff] [blame] | 94 | "libcore.javax.crypto" |
Roland Levillain | e0ce8bf | 2019-06-19 18:05:51 +0100 | [diff] [blame] | 95 | "libcore.javax.net" |
David Brazdil | 598b220 | 2015-02-24 10:12:06 +0000 | [diff] [blame] | 96 | "libcore.javax.security" |
| 97 | "libcore.javax.sql" |
| 98 | "libcore.javax.xml" |
Roland Levillain | 9b41e95 | 2019-06-19 18:20:07 +0100 | [diff] [blame] | 99 | "libcore.libcore.internal" |
Andreas Gampe | e166136 | 2017-11-08 16:42:14 -0800 | [diff] [blame] | 100 | "libcore.libcore.io" |
| 101 | "libcore.libcore.net" |
| 102 | "libcore.libcore.reflect" |
| 103 | "libcore.libcore.util" |
Roland Levillain | da5e041 | 2019-06-19 18:20:32 +0100 | [diff] [blame] | 104 | "libcore.libcore.timezone" |
Roland Levillain | c0ce3d5 | 2019-06-19 17:26:01 +0100 | [diff] [blame] | 105 | "libcore.sun.invoke" |
| 106 | "libcore.sun.net" |
| 107 | "libcore.sun.misc" |
| 108 | "libcore.sun.security" |
| 109 | "libcore.sun.util" |
Roland Levillain | ad82a81 | 2019-06-19 18:29:32 +0100 | [diff] [blame] | 110 | "libcore.xml" |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 111 | "org.apache.harmony.annotation" |
David Brazdil | 4cd7dfd | 2015-02-24 13:33:01 +0000 | [diff] [blame] | 112 | "org.apache.harmony.crypto" |
David Brazdil | e2f28ad | 2015-02-24 10:44:29 +0000 | [diff] [blame] | 113 | "org.apache.harmony.luni" |
| 114 | "org.apache.harmony.nio" |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 115 | "org.apache.harmony.regex" |
David Brazdil | e2f28ad | 2015-02-24 10:44:29 +0000 | [diff] [blame] | 116 | "org.apache.harmony.testframework" |
| 117 | "org.apache.harmony.tests.java.io" |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 118 | "org.apache.harmony.tests.java.lang" |
Nicolas Geoffray | c3837e4 | 2014-12-03 11:30:26 +0000 | [diff] [blame] | 119 | "org.apache.harmony.tests.java.math" |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 120 | "org.apache.harmony.tests.java.util" |
David Brazdil | e2f28ad | 2015-02-24 10:44:29 +0000 | [diff] [blame] | 121 | "org.apache.harmony.tests.java.text" |
| 122 | "org.apache.harmony.tests.javax.security" |
Wojciech Staszkiewicz | 08cf148 | 2015-05-21 17:31:38 +0100 | [diff] [blame] | 123 | "tests.java.lang.String" |
| 124 | "jsr166") |
Nicolas Geoffray | b2e7e24 | 2014-11-28 14:24:28 +0000 | [diff] [blame] | 125 | |
Nicolas Geoffray | cdcd000 | 2015-10-31 14:47:36 +0000 | [diff] [blame] | 126 | # List of packages we could run, but don't have rights to revert |
| 127 | # changes in case of failures. |
| 128 | # "org.apache.harmony.security" |
| 129 | |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 130 | vogar_args=$@ |
Nicolas Geoffray | 622e2e2 | 2017-06-15 09:33:01 +0100 | [diff] [blame] | 131 | gcstress=false |
| 132 | debug=false |
| 133 | |
Roland Levillain | d6e2c38 | 2019-09-18 16:13:48 +0100 | [diff] [blame] | 134 | # Run tests that use the getrandom() syscall? (Requires Linux 3.17+). |
| 135 | getrandom=true |
| 136 | |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 137 | # Don't use device mode by default. |
| 138 | device_mode=false |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 139 | |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 140 | while true; do |
| 141 | if [[ "$1" == "--mode=device" ]]; then |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 142 | device_mode=true |
Nicolas Geoffray | 191cae3 | 2019-01-09 09:36:03 +0000 | [diff] [blame] | 143 | # Remove the --mode=device from the arguments and replace it with --mode=device_testdex |
| 144 | vogar_args=${vogar_args/$1} |
| 145 | vogar_args="$vogar_args --mode=device_testdex" |
Nicolas Geoffray | b76bc78 | 2016-09-14 12:33:34 +0000 | [diff] [blame] | 146 | vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 147 | vogar_args="$vogar_args $(boot_classpath_arg /system/framework -testdex $BOOT_CLASSPATH_JARS)" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 148 | shift |
| 149 | elif [[ "$1" == "--mode=host" ]]; then |
Andreas Gampe | 8994a04 | 2015-12-30 19:03:17 +0000 | [diff] [blame] | 150 | # We explicitly give a wrong path for the image, to ensure vogar |
| 151 | # will create a boot image with the default compiler. Note that |
| 152 | # giving an existing image on host does not work because of |
| 153 | # classpath/resources differences when compiling the boot image. |
| 154 | vogar_args="$vogar_args --vm-arg -Ximage:/non/existent/vogar.art" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 155 | shift |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 156 | elif [[ "$1" == "--no-jit" ]]; then |
| 157 | # Remove the --no-jit from the arguments. |
| 158 | vogar_args=${vogar_args/$1} |
| 159 | use_jit=false |
| 160 | shift |
Nicolas Geoffray | 7f43791 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 161 | elif [[ "$1" == "--debug" ]]; then |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 162 | # Remove the --debug from the arguments. |
| 163 | vogar_args=${vogar_args/$1} |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 164 | vogar_args="$vogar_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true" |
Nicolas Geoffray | 622e2e2 | 2017-06-15 09:33:01 +0100 | [diff] [blame] | 165 | debug=true |
| 166 | shift |
| 167 | elif [[ "$1" == "-Xgc:gcstress" ]]; then |
| 168 | gcstress=true |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 169 | shift |
Roland Levillain | d6e2c38 | 2019-09-18 16:13:48 +0100 | [diff] [blame] | 170 | elif [[ "$1" == "--no-getrandom" ]]; then |
Roland Levillain | 8df75ed | 2019-09-19 18:34:05 +0100 | [diff] [blame] | 171 | # Remove the option from Vogar arguments. |
| 172 | vogar_args=${vogar_args/$1} |
Roland Levillain | d6e2c38 | 2019-09-18 16:13:48 +0100 | [diff] [blame] | 173 | getrandom=false |
| 174 | shift |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 175 | elif [[ "$1" == "" ]]; then |
| 176 | break |
| 177 | else |
| 178 | shift |
| 179 | fi |
| 180 | done |
| 181 | |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 182 | if $device_mode; then |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 183 | # Honor environment variable ART_TEST_CHROOT. |
| 184 | if [[ -n "$ART_TEST_CHROOT" ]]; then |
| 185 | # Set Vogar's `--chroot` option. |
| 186 | vogar_args="$vogar_args --chroot $ART_TEST_CHROOT" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 187 | vogar_args="$vogar_args --device-dir=/tmp" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 188 | else |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 189 | # When not using a chroot on device, set Vogar's work directory to |
| 190 | # /data/local/tmp. |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 191 | vogar_args="$vogar_args --device-dir=/data/local/tmp" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 192 | fi |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 193 | vogar_args="$vogar_args --vm-command=$android_root/bin/art" |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 194 | fi |
| 195 | |
Nicolas Geoffray | 44368e8 | 2015-09-30 12:02:21 +0100 | [diff] [blame] | 196 | # Increase the timeout, as vogar cannot set individual test |
| 197 | # timeout when being asked to run packages, and some tests go above |
| 198 | # the default timeout. |
Nicolas Geoffray | a353ce5 | 2018-08-06 09:28:20 +0100 | [diff] [blame] | 199 | if $gcstress && $debug && $device_mode; then |
Nicolas Geoffray | 793bed3 | 2018-08-22 15:07:40 +0100 | [diff] [blame] | 200 | vogar_args="$vogar_args --timeout 1440" |
David Srbecky | 2bdda93 | 2019-10-08 14:26:25 +0100 | [diff] [blame] | 201 | elif $gcstress && $device_mode; then |
| 202 | vogar_args="$vogar_args --timeout 900" |
Nicolas Geoffray | a353ce5 | 2018-08-06 09:28:20 +0100 | [diff] [blame] | 203 | else |
| 204 | vogar_args="$vogar_args --timeout 480" |
| 205 | fi |
Nicolas Geoffray | f794ad7 | 2015-09-11 12:08:49 +0100 | [diff] [blame] | 206 | |
Neil Fuller | 239bdf6 | 2018-01-08 18:55:36 +0000 | [diff] [blame] | 207 | # set the toolchain to use. |
| 208 | vogar_args="$vogar_args --toolchain d8 --language CUR" |
Neil Fuller | b8300fc | 2016-02-10 13:09:10 +0000 | [diff] [blame] | 209 | |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 210 | # JIT settings. |
| 211 | if $use_jit; then |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 212 | vogar_args="$vogar_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken" |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 213 | fi |
| 214 | vogar_args="$vogar_args --vm-arg -Xusejit:$use_jit" |
| 215 | |
Nicolas Geoffray | 5b455d3 | 2017-07-05 10:51:06 +0100 | [diff] [blame] | 216 | # gcstress may lead to timeouts, so we need dedicated expectations files for it. |
Nicolas Geoffray | a655575 | 2018-05-02 10:39:09 +0100 | [diff] [blame] | 217 | if $gcstress; then |
Nicolas Geoffray | 5b455d3 | 2017-07-05 10:51:06 +0100 | [diff] [blame] | 218 | expectations="$expectations --expectations art/tools/libcore_gcstress_failures.txt" |
Nicolas Geoffray | a655575 | 2018-05-02 10:39:09 +0100 | [diff] [blame] | 219 | if $debug; then |
Nicolas Geoffray | 5b455d3 | 2017-07-05 10:51:06 +0100 | [diff] [blame] | 220 | expectations="$expectations --expectations art/tools/libcore_gcstress_debug_failures.txt" |
| 221 | fi |
Nicolas Geoffray | a655575 | 2018-05-02 10:39:09 +0100 | [diff] [blame] | 222 | else |
| 223 | # We only run this package when not under gcstress as it can cause timeouts. See b/78228743. |
| 224 | working_packages+=("libcore.libcore.icu") |
Nicolas Geoffray | 622e2e2 | 2017-06-15 09:33:01 +0100 | [diff] [blame] | 225 | fi |
| 226 | |
Roland Levillain | d6e2c38 | 2019-09-18 16:13:48 +0100 | [diff] [blame] | 227 | if $getrandom; then :; else |
| 228 | # Ignore failures in tests that use the getrandom() syscall (which requires |
| 229 | # Linux 3.17+). This is needed on fugu (Nexus Player) devices, where the |
| 230 | # kernel is Linux 3.10. |
| 231 | expectations="$expectations --expectations art/tools/libcore_no_getrandom_failures.txt" |
| 232 | fi |
| 233 | |
Nicolas Geoffray | b2e7e24 | 2014-11-28 14:24:28 +0000 | [diff] [blame] | 234 | # Run the tests using vogar. |
Nicolas Geoffray | 3cdf818 | 2014-12-01 10:12:15 +0000 | [diff] [blame] | 235 | echo "Running tests for the following test packages:" |
| 236 | echo ${working_packages[@]} | tr " " "\n" |
Nicolas Geoffray | 793bed3 | 2018-08-22 15:07:40 +0100 | [diff] [blame] | 237 | |
| 238 | cmd="vogar $vogar_args $expectations $(cparg $DEPS) ${working_packages[@]}" |
| 239 | echo "Running $cmd" |
| 240 | eval $cmd |