Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2015 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_HOST_OUT" ] ; then |
| 26 | ANDROID_HOST_OUT=${OUT_DIR-$ANDROID_BUILD_TOP/out}/host/linux-x86 |
| 27 | fi |
| 28 | |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 29 | # "Root" (actually "system") directory on device (in the case of |
| 30 | # target testing). |
| 31 | android_root=${ART_TEST_ANDROID_ROOT:-/system} |
Roland Levillain | 1c36188 | 2018-03-02 14:23:51 +0000 | [diff] [blame] | 32 | |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 33 | java_lib_location="${ANDROID_HOST_OUT}/../common/obj/JAVA_LIBRARIES" |
| 34 | make_target_name="apache-harmony-jdwp-tests-hostdex" |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 35 | |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 36 | function boot_classpath_arg { |
| 37 | local dir="$1" |
| 38 | local suffix="$2" |
| 39 | shift 2 |
| 40 | local separator="" |
| 41 | for var |
| 42 | do |
| 43 | printf -- "${separator}${dir}/${var}${suffix}.jar"; |
| 44 | separator=":" |
| 45 | done |
| 46 | } |
| 47 | |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 48 | # 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] | 49 | # because that's what we use for compiling the core.art image. |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 50 | # It may contain additional modules from TEST_CORE_JARS. |
Victor Chang | 759845f | 2019-08-06 16:04:36 +0100 | [diff] [blame] | 51 | 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] | 52 | |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 53 | vm_args="" |
Roland Levillain | 1c36188 | 2018-03-02 14:23:51 +0000 | [diff] [blame] | 54 | art="$android_root/bin/art" |
| 55 | art_debugee="sh $android_root/bin/art" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 56 | args=$@ |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 57 | chroot_option= |
Nicolas Geoffray | d553b43 | 2015-07-13 14:35:17 +0100 | [diff] [blame] | 58 | debuggee_args="-Xcompiler-option --debuggable" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 59 | device_dir="--device-dir=/data/local/tmp" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 60 | # We use the art script on target to ensure the runner and the debuggee share the same |
| 61 | # image. |
| 62 | vm_command="--vm-command=$art" |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 63 | image_compiler_option="" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 64 | plugin="" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 65 | debug="no" |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 66 | explicit_debug="no" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 67 | verbose="no" |
Nicolas Geoffray | b76bc78 | 2016-09-14 12:33:34 +0000 | [diff] [blame] | 68 | image="-Ximage:/data/art-test/core.art" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 69 | boot_classpath="$(boot_classpath_arg /system/framework -testdex $BOOT_CLASSPATH_JARS)" |
| 70 | boot_classpath_locations="" |
Alex Light | 0ac2e5c | 2017-09-19 15:35:20 -0700 | [diff] [blame] | 71 | with_jdwp_path="" |
| 72 | agent_wrapper="" |
Nicolas Geoffray | 9518655 | 2015-10-28 13:06:21 +0000 | [diff] [blame] | 73 | vm_args="" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 74 | # By default, we run the whole JDWP test suite. |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 75 | has_specific_test="no" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 76 | test="org.apache.harmony.jpda.tests.share.AllTests" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 77 | mode="target" |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 78 | # Use JIT compiling by default. |
| 79 | use_jit=true |
Alex Light | d0d25fe | 2018-07-20 15:46:49 -0700 | [diff] [blame] | 80 | instant_jit=false |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 81 | variant_cmdline_parameter="--variant=X32" |
Alex Light | 878f33f | 2018-02-08 11:16:39 -0800 | [diff] [blame] | 82 | dump_command="/bin/true" |
Alex Light | bd5690d | 2019-09-30 15:39:15 -0700 | [diff] [blame] | 83 | called_from_libjdwp=${RUN_JDWP_TESTS_CALLED_FROM_LIBJDWP:-false} |
| 84 | run_internal_jdwp_test=false |
| 85 | # Let LUCI bots do what they want. |
| 86 | if test -v LUCI_CONTEXT; then |
| 87 | run_internal_jdwp_test=true |
| 88 | fi |
Sebastien Hertz | c3b208c | 2017-03-27 11:35:54 +0200 | [diff] [blame] | 89 | # Timeout of JDWP test in ms. |
| 90 | # |
| 91 | # Note: some tests expect a timeout to check that *no* reply/event is received for a specific case. |
| 92 | # A lower timeout can save up several minutes when running the whole test suite, especially for |
| 93 | # continuous testing. This value can be adjusted to fit the configuration of the host machine(s). |
| 94 | jdwp_test_timeout=10000 |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 95 | |
Alex Light | 7fca6ef | 2019-10-02 09:24:20 -0700 | [diff] [blame] | 96 | skip_tests= |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 97 | gdb_target= |
| 98 | has_gdb="no" |
| 99 | |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 100 | while true; do |
| 101 | if [[ "$1" == "--mode=host" ]]; then |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 102 | mode="host" |
Nicolas Geoffray | 5978690 | 2015-03-30 16:34:16 +0100 | [diff] [blame] | 103 | # Specify bash explicitly since the art script cannot, since it has to run on the device |
| 104 | # with mksh. |
Alex Light | b15fea2 | 2015-09-17 16:59:09 -0700 | [diff] [blame] | 105 | art="bash ${OUT_DIR-out}/host/linux-x86/bin/art" |
| 106 | art_debugee="bash ${OUT_DIR-out}/host/linux-x86/bin/art" |
Andreas Gampe | 8994a04 | 2015-12-30 19:03:17 +0000 | [diff] [blame] | 107 | # We force generation of a new image to avoid build-time and run-time classpath differences. |
| 108 | image="-Ximage:/system/non/existent/vogar.art" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 109 | # Pass the host boot classpath. |
| 110 | if [ "${ANDROID_HOST_OUT:0:${#ANDROID_BUILD_TOP}+1}" = "${ANDROID_BUILD_TOP}/" ]; then |
| 111 | framework_location="${ANDROID_HOST_OUT:${#ANDROID_BUILD_TOP}+1}/framework" |
| 112 | else |
| 113 | echo "error: ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT" |
| 114 | echo "ANDROID_BUILD_TOP=${ANDROID_BUILD_TOP}" |
| 115 | echo "ANDROID_HOST_OUT=${ANDROID_HOST_OUT}" |
| 116 | exit |
| 117 | fi |
| 118 | boot_classpath="$(boot_classpath_arg ${ANDROID_HOST_OUT}/framework -hostdex $BOOT_CLASSPATH_JARS)" |
| 119 | boot_classpath_locations="$(boot_classpath_arg ${framework_location} -hostdex $BOOT_CLASSPATH_JARS)" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 120 | # We do not need a device directory on host. |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 121 | device_dir="" |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 122 | # Vogar knows which VM to use on host. |
| 123 | vm_command="" |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 124 | shift |
Nicolas Geoffray | 191cae3 | 2019-01-09 09:36:03 +0000 | [diff] [blame] | 125 | elif [[ "$1" == "--mode=device" ]]; then |
| 126 | # Remove the --mode=device from the arguments and replace it with --mode=device_testdex |
| 127 | args=${args/$1} |
| 128 | args="$args --mode=device_testdex" |
| 129 | shift |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 130 | elif [[ "$1" == "--mode=jvm" ]]; then |
| 131 | mode="ri" |
Paul Duffin | 5071531 | 2019-07-11 15:44:25 +0100 | [diff] [blame] | 132 | make_target_name="apache-harmony-jdwp-tests" |
Alex Light | bd5690d | 2019-09-30 15:39:15 -0700 | [diff] [blame] | 133 | run_internal_jdwp_test=true |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 134 | art="$(which java)" |
| 135 | art_debugee="$(which java)" |
| 136 | # No need for extra args. |
| 137 | debuggee_args="" |
| 138 | # No image. On the RI. |
| 139 | image="" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 140 | boot_classpath="" |
| 141 | boot_classpath_locations="" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 142 | # We do not need a device directory on RI. |
| 143 | device_dir="" |
| 144 | # Vogar knows which VM to use on RI. |
| 145 | vm_command="" |
| 146 | # We don't care about jit with the RI |
| 147 | use_jit=false |
| 148 | shift |
Alex Light | 7fca6ef | 2019-10-02 09:24:20 -0700 | [diff] [blame] | 149 | elif [[ $1 == --skip-test ]]; then |
| 150 | skip_tests="${skip_tests},${2}" |
| 151 | # remove the --skip-test |
| 152 | args=${args/$1} |
| 153 | shift |
| 154 | # remove the arg |
| 155 | args=${args/$1} |
| 156 | shift |
Alex Light | bd5690d | 2019-09-30 15:39:15 -0700 | [diff] [blame] | 157 | elif [[ $1 == --force-run-test ]]; then |
| 158 | run_internal_jdwp_test=true |
| 159 | # remove the --force-run-test |
| 160 | args=${args/$1} |
| 161 | shift |
Alex Light | ec4a10c | 2017-11-17 09:06:26 -0800 | [diff] [blame] | 162 | elif [[ $1 == --test-timeout-ms ]]; then |
| 163 | # Remove the --test-timeout-ms from the arguments. |
| 164 | args=${args/$1} |
| 165 | shift |
| 166 | jdwp_test_timeout=$1 |
| 167 | # Remove the argument |
| 168 | args=${args/$1} |
| 169 | shift |
Alex Light | 0ac2e5c | 2017-09-19 15:35:20 -0700 | [diff] [blame] | 170 | elif [[ $1 == --agent-wrapper ]]; then |
| 171 | # Remove the --agent-wrapper from the arguments. |
| 172 | args=${args/$1} |
| 173 | shift |
| 174 | agent_wrapper=${agent_wrapper}${1}, |
| 175 | # Remove the argument |
| 176 | args=${args/$1} |
| 177 | shift |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 178 | elif [[ $1 == -Ximage:* ]]; then |
| 179 | image="$1" |
| 180 | shift |
Alex Light | d0d25fe | 2018-07-20 15:46:49 -0700 | [diff] [blame] | 181 | elif [[ "$1" == "--instant-jit" ]]; then |
| 182 | instant_jit=true |
| 183 | # Remove the --instant-jit from the arguments. |
| 184 | args=${args/$1} |
| 185 | shift |
Roland Levillain | 5db109b | 2016-05-19 12:24:17 +0100 | [diff] [blame] | 186 | elif [[ "$1" == "--no-jit" ]]; then |
| 187 | use_jit=false |
| 188 | # Remove the --no-jit from the arguments. |
| 189 | args=${args/$1} |
| 190 | shift |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 191 | elif [[ $1 == "--no-debug" ]]; then |
| 192 | explicit_debug="yes" |
| 193 | debug="no" |
| 194 | # Remove the --no-debug from the arguments. |
| 195 | args=${args/$1} |
| 196 | shift |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 197 | elif [[ $1 == "--debug" ]]; then |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 198 | explicit_debug="yes" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 199 | debug="yes" |
| 200 | # Remove the --debug from the arguments. |
| 201 | args=${args/$1} |
| 202 | shift |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 203 | elif [[ $1 == "--verbose" ]]; then |
| 204 | verbose="yes" |
| 205 | # Remove the --verbose from the arguments. |
| 206 | args=${args/$1} |
| 207 | shift |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 208 | elif [[ $1 == "--gdbserver" ]]; then |
| 209 | # Remove the --gdbserver from the arguments. |
| 210 | args=${args/$1} |
| 211 | has_gdb="yes" |
| 212 | shift |
| 213 | gdb_target=$1 |
| 214 | # Remove the target from the arguments. |
| 215 | args=${args/$1} |
| 216 | shift |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 217 | elif [[ $1 == "--test" ]]; then |
| 218 | # Remove the --test from the arguments. |
| 219 | args=${args/$1} |
| 220 | shift |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 221 | has_specific_test="yes" |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 222 | test=$1 |
| 223 | # Remove the test from the arguments. |
| 224 | args=${args/$1} |
| 225 | shift |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 226 | elif [[ "$1" == "--jdwp-path" ]]; then |
| 227 | # Remove the --jdwp-path from the arguments. |
| 228 | args=${args/$1} |
| 229 | shift |
Alex Light | 0ac2e5c | 2017-09-19 15:35:20 -0700 | [diff] [blame] | 230 | with_jdwp_path=$1 |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 231 | # Remove the path from the arguments. |
| 232 | args=${args/$1} |
| 233 | shift |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 234 | elif [[ "$1" == "" ]]; then |
| 235 | break |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 236 | elif [[ $1 == --variant=* ]]; then |
| 237 | variant_cmdline_parameter=$1 |
| 238 | shift |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 239 | elif [[ $1 == -Xplugin:* ]]; then |
| 240 | plugin="$1" |
| 241 | args=${args/$1} |
| 242 | shift |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 243 | else |
| 244 | shift |
| 245 | fi |
| 246 | done |
| 247 | |
Roland Levillain | 0331a0f | 2020-01-22 16:08:39 +0000 | [diff] [blame] | 248 | if [ ! -t 1 ] ; then |
| 249 | # Suppress color codes if not attached to a terminal |
| 250 | args="$args --no-color" |
| 251 | fi |
| 252 | |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 253 | if [[ $mode == "target" ]]; then |
| 254 | # Honor environment variable ART_TEST_CHROOT. |
| 255 | if [[ -n "$ART_TEST_CHROOT" ]]; then |
| 256 | # Set Vogar's `--chroot` option. |
| 257 | chroot_option="--chroot $ART_TEST_CHROOT" |
| 258 | # Adjust settings for chroot environment. |
| 259 | art="/system/bin/art" |
| 260 | art_debugee="sh /system/bin/art" |
| 261 | vm_command="--vm-command=$art" |
| 262 | device_dir="--device-dir=/tmp" |
| 263 | fi |
Roland Levillain | e4f1c51 | 2017-10-30 13:28:28 +0000 | [diff] [blame] | 264 | fi |
| 265 | |
Alex Light | bd5690d | 2019-09-30 15:39:15 -0700 | [diff] [blame] | 266 | if [[ $called_from_libjdwp != "true" ]]; then |
| 267 | if [[ $run_internal_jdwp_test = "false" ]]; then |
| 268 | echo "Calling run_jdwp_tests.sh directly is probably not what you want. You probably want to" |
| 269 | echo "run ./art/tools/run-libjdwp-tests.sh instead in order to test the JDWP implementation" |
| 270 | echo "used by apps. If you really wish to run these tests using the deprecated internal JDWP" |
| 271 | echo "implementation pass the '--force-run-test' flag." |
| 272 | exit 1 |
| 273 | fi |
| 274 | fi |
| 275 | |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 276 | if [[ $has_gdb = "yes" ]]; then |
| 277 | if [[ $explicit_debug = "no" ]]; then |
| 278 | debug="yes" |
| 279 | fi |
| 280 | fi |
| 281 | |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 282 | if [[ $mode == "ri" ]]; then |
Alex Light | 0ac2e5c | 2017-09-19 15:35:20 -0700 | [diff] [blame] | 283 | if [[ "x$with_jdwp_path" != "x" ]]; then |
| 284 | vm_args="${vm_args} --vm-arg -Djpda.settings.debuggeeAgentArgument=-agentpath:${agent_wrapper}" |
| 285 | vm_args="${vm_args} --vm-arg -Djpda.settings.debuggeeAgentName=$with_jdwp_path" |
| 286 | fi |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 287 | if [[ "x$image" != "x" ]]; then |
| 288 | echo "Cannot use -Ximage: with --mode=jvm" |
| 289 | exit 1 |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 290 | elif [[ $has_gdb = "yes" ]]; then |
| 291 | echo "Cannot use --gdbserver with --mode=jvm" |
| 292 | exit 1 |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 293 | elif [[ $debug == "yes" ]]; then |
| 294 | echo "Cannot use --debug with --mode=jvm" |
| 295 | exit 1 |
| 296 | fi |
| 297 | else |
Alex Light | 878f33f | 2018-02-08 11:16:39 -0800 | [diff] [blame] | 298 | if [[ "$mode" == "host" ]]; then |
| 299 | dump_command="/bin/kill -3" |
| 300 | else |
Roland Levillain | b52dbb7 | 2018-05-01 14:03:45 +0100 | [diff] [blame] | 301 | # Note that this dumping command won't work when `$android_root` |
| 302 | # is different from `/system` (e.g. on ART Buildbot devices) when |
| 303 | # the device is running Android N, as the debuggerd protocol |
| 304 | # changed in an incompatible way in Android O (see b/32466479). |
| 305 | dump_command="$android_root/xbin/su root $android_root/bin/debuggerd" |
Alex Light | 878f33f | 2018-02-08 11:16:39 -0800 | [diff] [blame] | 306 | fi |
Alex Light | 84b92e0 | 2017-09-29 13:46:14 -0700 | [diff] [blame] | 307 | if [[ $has_gdb = "yes" ]]; then |
| 308 | if [[ $mode == "target" ]]; then |
| 309 | echo "Cannot use --gdbserver with --mode=target" |
| 310 | exit 1 |
| 311 | else |
| 312 | art_debugee="$art_debugee --gdbserver $gdb_target" |
| 313 | # The tests absolutely require some timeout. We set a ~2 week timeout since we can kill the |
| 314 | # test with gdb if it goes on too long. |
| 315 | jdwp_test_timeout="1000000000" |
| 316 | fi |
| 317 | fi |
Alex Light | 0ac2e5c | 2017-09-19 15:35:20 -0700 | [diff] [blame] | 318 | if [[ "x$with_jdwp_path" != "x" ]]; then |
| 319 | vm_args="${vm_args} --vm-arg -Djpda.settings.debuggeeAgentArgument=-agentpath:${agent_wrapper}" |
| 320 | vm_args="${vm_args} --vm-arg -Djpda.settings.debuggeeAgentName=${with_jdwp_path}" |
| 321 | fi |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 322 | vm_args="$vm_args --vm-arg -Xcompiler-option --vm-arg --debuggable" |
Alex Light | baac7e4 | 2018-06-08 15:30:11 +0000 | [diff] [blame] | 323 | # we don't want to be trying to connect to adbconnection which might not have |
| 324 | # been built. |
| 325 | vm_args="${vm_args} --vm-arg -XjdwpProvider:none" |
Nicolas Geoffray | f983c73 | 2018-09-12 09:27:29 +0100 | [diff] [blame] | 326 | # Make sure the debuggee doesn't re-generate, nor clean up what the debugger has generated. |
| 327 | art_debugee="$art_debugee --no-compile --no-clean" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 328 | fi |
| 329 | |
| 330 | function jlib_name { |
| 331 | local path=$1 |
| 332 | local str="classes" |
| 333 | local suffix="jar" |
| 334 | if [[ $mode == "ri" ]]; then |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 335 | str="javalib" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 336 | fi |
| 337 | echo "$path/$str.$suffix" |
| 338 | } |
| 339 | |
| 340 | # Jar containing all the tests. |
| 341 | test_jar=$(jlib_name "${java_lib_location}/${make_target_name}_intermediates") |
| 342 | |
| 343 | if [[ ! -f $test_jar ]]; then |
| 344 | echo "Before running, you must build jdwp tests and vogar:" \ |
Roland Levillain | e47933a | 2019-08-09 14:06:02 +0100 | [diff] [blame] | 345 | "m ${make_target_name} vogar" |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 346 | exit 1 |
| 347 | fi |
Nicolas Geoffray | c0c0785 | 2017-08-08 09:44:15 +0100 | [diff] [blame] | 348 | |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 349 | # For the host: |
| 350 | # |
| 351 | # If, on the other hand, there is a variant set, use it to modify the art_debugee parameter to |
| 352 | # force the fork to have the same bitness as the controller. This should be fine and not impact |
| 353 | # testing (cross-bitness), as the protocol is always 64-bit anyways (our implementation). |
| 354 | # |
| 355 | # Note: this isn't necessary for the device as the BOOTCLASSPATH environment variable is set there |
| 356 | # and used as a fallback. |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 357 | if [[ $mode == "host" ]]; then |
Andreas Gampe | 85b286b | 2015-12-30 19:37:48 -0800 | [diff] [blame] | 358 | variant=${variant_cmdline_parameter:10} |
| 359 | if [[ $variant == "x32" || $variant == "X32" ]]; then |
| 360 | art_debugee="$art_debugee --32" |
| 361 | elif [[ $variant == "x64" || $variant == "X64" ]]; then |
| 362 | art_debugee="$art_debugee --64" |
| 363 | else |
| 364 | echo "Error, do not understand variant $variant_cmdline_parameter." |
| 365 | exit 1 |
| 366 | fi |
| 367 | fi |
| 368 | |
Nicolas Geoffray | 9518655 | 2015-10-28 13:06:21 +0000 | [diff] [blame] | 369 | if [[ "$image" != "" ]]; then |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 370 | vm_args="$vm_args --vm-arg $image" |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 371 | debuggee_args="$debuggee_args $image" |
| 372 | fi |
| 373 | if [[ "$boot_classpath" != "" ]]; then |
| 374 | vm_args="$vm_args --vm-arg -Xbootclasspath:${boot_classpath}" |
| 375 | debuggee_args="$debuggee_args -Xbootclasspath:${boot_classpath}" |
| 376 | fi |
| 377 | if [[ "$boot_classpath_locations" != "" ]]; then |
| 378 | vm_args="$vm_args --vm-arg -Xbootclasspath-locations:${boot_classpath_locations}" |
| 379 | debuggee_args="$debuggee_args -Xbootclasspath-locations:${boot_classpath_locations}" |
Nicolas Geoffray | 9518655 | 2015-10-28 13:06:21 +0000 | [diff] [blame] | 380 | fi |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 381 | |
| 382 | if [[ "$plugin" != "" ]]; then |
| 383 | vm_args="$vm_args --vm-arg $plugin" |
| 384 | fi |
| 385 | |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 386 | if [[ $mode != "ri" ]]; then |
Andreas Gampe | 817dc66 | 2018-09-25 18:08:52 -0700 | [diff] [blame] | 387 | # Because we're running debuggable, we discard any AOT code. |
| 388 | # Therefore we run de2oat with 'quicken' to avoid spending time compiling. |
| 389 | vm_args="$vm_args --vm-arg -Xcompiler-option --vm-arg --compiler-filter=quicken" |
| 390 | debuggee_args="$debuggee_args -Xcompiler-option --compiler-filter=quicken" |
| 391 | |
| 392 | if $instant_jit; then |
| 393 | debuggee_args="$debuggee_args -Xjitthreshold:0" |
| 394 | fi |
| 395 | |
Alex Light | 617c9c5 | 2017-08-18 11:52:25 -0700 | [diff] [blame] | 396 | vm_args="$vm_args --vm-arg -Xusejit:$use_jit" |
| 397 | debuggee_args="$debuggee_args -Xusejit:$use_jit" |
| 398 | fi |
| 399 | |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 400 | if [[ $debug == "yes" ]]; then |
| 401 | art="$art -d" |
| 402 | art_debugee="$art_debugee -d" |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 403 | vm_args="$vm_args --vm-arg -XXlib:libartd.so --vm-arg -XX:SlowDebug=true" |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 404 | fi |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 405 | if [[ $verbose == "yes" ]]; then |
| 406 | # Enable JDWP logs in the debuggee. |
| 407 | art_debugee="$art_debugee -verbose:jdwp" |
| 408 | fi |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 409 | |
Neil Fuller | 239bdf6 | 2018-01-08 18:55:36 +0000 | [diff] [blame] | 410 | if [[ $mode != "ri" ]]; then |
Neil Fuller | c546ec9 | 2018-01-05 15:00:35 +0000 | [diff] [blame] | 411 | toolchain_args="--toolchain d8 --language CUR" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 412 | if [[ "x$with_jdwp_path" == "x" ]]; then |
| 413 | # Need to enable the internal jdwp implementation. |
| 414 | art_debugee="${art_debugee} -XjdwpProvider:internal" |
Alex Light | baac7e4 | 2018-06-08 15:30:11 +0000 | [diff] [blame] | 415 | else |
| 416 | # need to disable the jdwpProvider since we give the agent explicitly on the |
| 417 | # cmdline. |
| 418 | art_debugee="${art_debugee} -XjdwpProvider:none" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 419 | fi |
Alex Light | 8d8299d | 2017-11-10 08:41:04 -0800 | [diff] [blame] | 420 | else |
| 421 | toolchain_args="--toolchain javac --language CUR" |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 422 | fi |
| 423 | |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 424 | # Run the tests using vogar. |
Nicolas Geoffray | d06dc9c | 2015-03-30 15:30:26 +0100 | [diff] [blame] | 425 | vogar $vm_command \ |
Nicolas Geoffray | 9648a63 | 2015-06-15 14:35:01 +0100 | [diff] [blame] | 426 | $vm_args \ |
Nicolas Geoffray | 9620b9d | 2015-03-30 12:28:26 +0100 | [diff] [blame] | 427 | --verbose \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 428 | $args \ |
Roland Levillain | 08f7c1d | 2018-05-25 15:34:41 +0100 | [diff] [blame] | 429 | $chroot_option \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 430 | $device_dir \ |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 431 | $image_compiler_option \ |
Nicolas Geoffray | 472b00c | 2015-05-06 14:57:09 +0100 | [diff] [blame] | 432 | --timeout 800 \ |
Nicolas Geoffray | 96cd87a | 2015-03-26 16:48:29 +0000 | [diff] [blame] | 433 | --vm-arg -Djpda.settings.verbose=true \ |
Sebastien Hertz | c3b208c | 2017-03-27 11:35:54 +0200 | [diff] [blame] | 434 | --vm-arg -Djpda.settings.timeout=$jdwp_test_timeout \ |
| 435 | --vm-arg -Djpda.settings.waitingTime=$jdwp_test_timeout \ |
Nicolas Geoffray | a2c1861 | 2015-03-30 23:01:28 +0100 | [diff] [blame] | 436 | --vm-arg -Djpda.settings.transportAddress=127.0.0.1:55107 \ |
Alex Light | 878f33f | 2018-02-08 11:16:39 -0800 | [diff] [blame] | 437 | --vm-arg -Djpda.settings.dumpProcess="$dump_command" \ |
Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 438 | --vm-arg -Djpda.settings.debuggeeJavaPath="$art_debugee $plugin $debuggee_args" \ |
Alex Light | 7fca6ef | 2019-10-02 09:24:20 -0700 | [diff] [blame] | 439 | --vm-arg -Djpda.settings.badTestCases="$skip_tests" \ |
Igor Murashkin | 84f2632 | 2017-06-06 11:36:33 -0700 | [diff] [blame] | 440 | --classpath "$test_jar" \ |
| 441 | $toolchain_args \ |
Sebastien Hertz | a646aaf | 2015-09-10 12:03:51 +0200 | [diff] [blame] | 442 | $test |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 443 | |
| 444 | vogar_exit_status=$? |
| 445 | |
| 446 | echo "Killing stalled dalvikvm processes..." |
Alex Light | c611ffa | 2017-10-18 08:59:16 -0700 | [diff] [blame] | 447 | if [[ $mode == "host" ]]; then |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 448 | pkill -9 -f /bin/dalvikvm |
| 449 | else |
Orion Hodson | cfb4ed5 | 2018-05-22 10:48:52 +0100 | [diff] [blame] | 450 | # Tests may run on older Android versions where pkill requires "-l SIGNAL" |
| 451 | # rather than "-SIGNAL". |
| 452 | adb shell pkill -l 9 -f /bin/dalvikvm |
Hiroshi Yamauchi | a166bbb | 2015-11-19 16:24:31 -0800 | [diff] [blame] | 453 | fi |
| 454 | echo "Done." |
| 455 | |
| 456 | exit $vogar_exit_status |