Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Runner for an individual run-test. |
| 4 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 5 | if [[ -z "$ANDROID_BUILD_TOP" ]]; then |
| 6 | echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 10 | msg() { |
| 11 | if [ "$QUIET" = "n" ]; then |
| 12 | echo "$@" |
| 13 | fi |
| 14 | } |
| 15 | |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 16 | ANDROID_ROOT="/system" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 17 | ANDROID_ART_ROOT="/apex/com.android.art" |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 18 | ANDROID_I18N_ROOT="/apex/com.android.i18n" |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 19 | ANDROID_TZDATA_ROOT="/apex/com.android.tzdata" |
Vladimir Marko | be0d3cf | 2020-02-12 10:52:22 +0000 | [diff] [blame] | 20 | ARCHITECTURES_32="(arm|x86|none)" |
| 21 | ARCHITECTURES_64="(arm64|x86_64|none)" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 22 | ARCHITECTURES_PATTERN="${ARCHITECTURES_32}" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 23 | GET_DEVICE_ISA_BITNESS_FLAG="--32" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 24 | BOOT_IMAGE="" |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 25 | CHROOT= |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 26 | COMPILE_FLAGS="" |
| 27 | DALVIKVM="dalvikvm32" |
| 28 | DEBUGGER="n" |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 29 | WITH_AGENT=() |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 30 | DEBUGGER_AGENT="" |
| 31 | WRAP_DEBUGGER_AGENT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 32 | DEV_MODE="n" |
Roland Levillain | 15c622d | 2020-02-19 16:24:10 +0000 | [diff] [blame^] | 33 | DEX2OAT_NDEBUG_BINARY="dex2oat" |
| 34 | DEX2OAT_DEBUG_BINARY="dex2oatd" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 35 | EXPERIMENTAL="" |
Nicolas Geoffray | 90355fe | 2017-02-20 09:25:40 +0000 | [diff] [blame] | 36 | FALSE_BIN="false" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 37 | FLAGS="" |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 38 | ANDROID_FLAGS="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 39 | GDB="" |
Nicolas Geoffray | baf9102 | 2014-10-08 09:56:45 +0100 | [diff] [blame] | 40 | GDB_ARGS="" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 41 | GDBSERVER_DEVICE="gdbserver" |
| 42 | GDBSERVER_HOST="gdbserver" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 43 | HAVE_IMAGE="y" |
| 44 | HOST="n" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 45 | BIONIC="n" |
| 46 | CREATE_ANDROID_ROOT="n" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 47 | USE_ZIPAPEX="n" |
| 48 | ZIPAPEX_LOC="" |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 49 | USE_EXTRACTED_ZIPAPEX="n" |
| 50 | EXTRACTED_ZIPAPEX_LOC="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 51 | INTERPRETER="n" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 52 | JIT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 53 | INVOKE_WITH="" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 54 | IS_JVMTI_TEST="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 55 | ISA=x86 |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 56 | LIBRARY_DIRECTORY="lib" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 57 | TEST_DIRECTORY="nativetest" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 58 | MAIN="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 59 | OPTIMIZE="y" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 60 | PREBUILD="y" |
| 61 | QUIET="n" |
Nicolas Geoffray | 94e25db | 2017-01-27 14:54:28 +0000 | [diff] [blame] | 62 | RELOCATE="n" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 63 | STRIP_DEX="n" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 64 | SECONDARY_DEX="" |
David Srbecky | 352482c | 2019-10-16 15:59:52 +0100 | [diff] [blame] | 65 | TIME_OUT="n" # "n" (disabled), "timeout" (use timeout), "gdb" (use gdb) |
Andreas Gampe | 148c160 | 2019-06-10 16:47:46 -0700 | [diff] [blame] | 66 | TIMEOUT_DUMPER=signal_dumper |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 67 | # Values in seconds. |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 68 | TIME_OUT_EXTRA=0 |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 69 | TIME_OUT_VALUE= |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 70 | USE_GDB="n" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 71 | USE_GDBSERVER="n" |
| 72 | GDBSERVER_PORT=":5039" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 73 | USE_JVM="n" |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 74 | USE_JVMTI="n" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 75 | VERIFY="y" # y=yes,n=no,s=softfail |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 76 | ZYGOTE="" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 77 | DEX_VERIFY="" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 78 | INSTRUCTION_SET_FEATURES="" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 79 | ARGS="" |
David Brazdil | feb2282 | 2019-02-13 21:25:57 +0000 | [diff] [blame] | 80 | VDEX_ARGS="" |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 81 | EXTERNAL_LOG_TAGS="n" # if y respect externally set ANDROID_LOG_TAGS. |
| 82 | DRY_RUN="n" # if y prepare to run the test but don't run it. |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 83 | TEST_VDEX="n" |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 84 | TEST_DM="n" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 85 | TEST_IS_NDEBUG="n" |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 86 | APP_IMAGE="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 87 | JVMTI_STRESS="n" |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 88 | JVMTI_STEP_STRESS="n" |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 89 | JVMTI_FIELD_STRESS="n" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 90 | JVMTI_TRACE_STRESS="n" |
| 91 | JVMTI_REDEFINE_STRESS="n" |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 92 | PROFILE="n" |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 93 | RANDOM_PROFILE="n" |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 94 | # The normal dex2oat timeout. |
Shubham Ajmera | f97cbd6 | 2017-10-11 10:00:57 -0700 | [diff] [blame] | 95 | DEX2OAT_TIMEOUT="300" # 5 mins |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 96 | # The *hard* timeout where we really start trying to kill the dex2oat. |
Shubham Ajmera | f97cbd6 | 2017-10-11 10:00:57 -0700 | [diff] [blame] | 97 | DEX2OAT_RT_TIMEOUT="360" # 6 mins |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 98 | CREATE_RUNNER="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 99 | |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 100 | # if "y", run 'sync' before dalvikvm to make sure all files from |
| 101 | # build step (e.g. dex2oat) were finished writing. |
| 102 | SYNC_BEFORE_RUN="n" |
| 103 | |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 104 | # When running a debug build, we want to run with all checks. |
| 105 | ANDROID_FLAGS="${ANDROID_FLAGS} -XX:SlowDebug=true" |
Andreas Gampe | e8f74ca | 2018-01-02 09:26:16 -0800 | [diff] [blame] | 106 | # The same for dex2oatd, both prebuild and runtime-driven. |
| 107 | ANDROID_FLAGS="${ANDROID_FLAGS} -Xcompiler-option --runtime-arg -Xcompiler-option -XX:SlowDebug=true" |
| 108 | COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -XX:SlowDebug=true" |
Andreas Gampe | 1c5b42f | 2017-06-15 18:20:45 -0700 | [diff] [blame] | 109 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 110 | while true; do |
| 111 | if [ "x$1" = "x--quiet" ]; then |
| 112 | QUIET="y" |
| 113 | shift |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 114 | elif [ "x$1" = "x--dex2oat-rt-timeout" ]; then |
| 115 | shift |
| 116 | if [ "x$1" = "x" ]; then |
| 117 | echo "$0 missing argument to --dex2oat-rt-timeout" 1>&2 |
| 118 | exit 1 |
| 119 | fi |
| 120 | DEX2OAT_RT_TIMEOUT="$1" |
| 121 | shift |
| 122 | elif [ "x$1" = "x--dex2oat-timeout" ]; then |
| 123 | shift |
| 124 | if [ "x$1" = "x" ]; then |
| 125 | echo "$0 missing argument to --dex2oat-timeout" 1>&2 |
| 126 | exit 1 |
| 127 | fi |
| 128 | DEX2OAT_TIMEOUT="$1" |
| 129 | shift |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 130 | elif [ "x$1" = "x--jvmti" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 131 | USE_JVMTI="y" |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 132 | IS_JVMTI_TEST="y" |
| 133 | shift |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 134 | elif [ "x$1" = "x-O" ]; then |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 135 | TEST_IS_NDEBUG="y" |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 136 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 137 | elif [ "x$1" = "x--lib" ]; then |
| 138 | shift |
| 139 | if [ "x$1" = "x" ]; then |
| 140 | echo "$0 missing argument to --lib" 1>&2 |
| 141 | exit 1 |
| 142 | fi |
| 143 | LIB="$1" |
| 144 | shift |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 145 | elif [ "x$1" = "x--gc-stress" ]; then |
David Srbecky | 7021c13 | 2019-10-04 12:56:22 +0100 | [diff] [blame] | 146 | # Give an extra 20 mins if we are gc-stress. |
| 147 | TIME_OUT_EXTRA=$((${TIME_OUT_EXTRA} + 1200)) |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 148 | shift |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 149 | elif [ "x$1" = "x--testlib" ]; then |
| 150 | shift |
| 151 | if [ "x$1" = "x" ]; then |
| 152 | echo "$0 missing argument to --testlib" 1>&2 |
| 153 | exit 1 |
| 154 | fi |
Mathieu Chartier | de286fd | 2015-09-03 18:10:29 -0700 | [diff] [blame] | 155 | ARGS="${ARGS} $1" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 156 | shift |
David Srbecky | 5288611 | 2016-01-22 13:56:47 +0000 | [diff] [blame] | 157 | elif [ "x$1" = "x--args" ]; then |
| 158 | shift |
| 159 | if [ "x$1" = "x" ]; then |
| 160 | echo "$0 missing argument to --args" 1>&2 |
| 161 | exit 1 |
| 162 | fi |
| 163 | ARGS="${ARGS} $1" |
| 164 | shift |
Alex Light | e2ddce3 | 2019-05-22 17:08:35 +0000 | [diff] [blame] | 165 | elif [ "x$1" = "x--compiler-only-option" ]; then |
| 166 | shift |
| 167 | option="$1" |
| 168 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 169 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 170 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 171 | shift |
| 172 | option="$1" |
| 173 | FLAGS="${FLAGS} -Xcompiler-option $option" |
| 174 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 175 | shift |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 176 | elif [ "x$1" = "x--create-runner" ]; then |
| 177 | CREATE_RUNNER="y" |
| 178 | shift |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 179 | elif [ "x$1" = "x--android-runtime-option" ]; then |
| 180 | shift |
| 181 | option="$1" |
| 182 | ANDROID_FLAGS="${ANDROID_FLAGS} $option" |
| 183 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 184 | elif [ "x$1" = "x--runtime-option" ]; then |
| 185 | shift |
| 186 | option="$1" |
| 187 | FLAGS="${FLAGS} $option" |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 188 | if [ "x$option" = "x-Xmethod-trace" ]; then |
Martin Stjernholm | 3067710 | 2019-10-01 12:54:10 +0100 | [diff] [blame] | 189 | # Method tracing can slow some tests down a lot, in particular |
| 190 | # 530-checker-lse2. |
| 191 | TIME_OUT_EXTRA=$((${TIME_OUT_EXTRA} + 1200)) |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 192 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 193 | shift |
| 194 | elif [ "x$1" = "x--boot" ]; then |
| 195 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 196 | BOOT_IMAGE="$1" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 197 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 198 | elif [ "x$1" = "x--relocate" ]; then |
| 199 | RELOCATE="y" |
| 200 | shift |
| 201 | elif [ "x$1" = "x--no-relocate" ]; then |
| 202 | RELOCATE="n" |
| 203 | shift |
| 204 | elif [ "x$1" = "x--prebuild" ]; then |
| 205 | PREBUILD="y" |
| 206 | shift |
Mathieu Chartier | dcd56c9 | 2017-11-20 20:30:24 -0800 | [diff] [blame] | 207 | elif [ "x$1" = "x--compact-dex-level" ]; then |
| 208 | shift |
| 209 | COMPILE_FLAGS="${COMPILE_FLAGS} --compact-dex-level=$1" |
| 210 | shift |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 211 | elif [ "x$1" = "x--jvmti-redefine-stress" ]; then |
| 212 | # APP_IMAGE doesn't really work with jvmti redefine stress |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 213 | USE_JVMTI="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 214 | APP_IMAGE="n" |
| 215 | JVMTI_STRESS="y" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 216 | JVMTI_REDEFINE_STRESS="y" |
| 217 | shift |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 218 | elif [ "x$1" = "x--jvmti-step-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 219 | USE_JVMTI="y" |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 220 | JVMTI_STRESS="y" |
| 221 | JVMTI_STEP_STRESS="y" |
| 222 | shift |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 223 | elif [ "x$1" = "x--jvmti-field-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 224 | USE_JVMTI="y" |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 225 | JVMTI_STRESS="y" |
| 226 | JVMTI_FIELD_STRESS="y" |
| 227 | shift |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 228 | elif [ "x$1" = "x--jvmti-trace-stress" ]; then |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 229 | USE_JVMTI="y" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 230 | JVMTI_STRESS="y" |
| 231 | JVMTI_TRACE_STRESS="y" |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 232 | shift |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 233 | elif [ "x$1" = "x--no-app-image" ]; then |
| 234 | APP_IMAGE="n" |
| 235 | shift |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 236 | elif [ "x$1" = "x--strip-dex" ]; then |
| 237 | STRIP_DEX="y" |
| 238 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 239 | elif [ "x$1" = "x--host" ]; then |
| 240 | HOST="y" |
Roland Levillain | b59f5fb | 2020-02-19 16:22:48 +0000 | [diff] [blame] | 241 | ANDROID_ROOT="${ANDROID_HOST_OUT}" |
| 242 | ANDROID_ART_ROOT="${ANDROID_HOST_OUT}/com.android.art" |
| 243 | ANDROID_I18N_ROOT="${ANDROID_HOST_OUT}/com.android.i18n" |
| 244 | ANDROID_TZDATA_ROOT="${ANDROID_HOST_OUT}/com.android.tzdata" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 245 | shift |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 246 | elif [ "x$1" = "x--bionic" ]; then |
| 247 | BIONIC="y" |
| 248 | # We need to create an ANDROID_ROOT because currently we cannot create |
| 249 | # the frameworks/libcore with linux_bionic so we need to use the normal |
| 250 | # host ones which are in a different location. |
| 251 | CREATE_ANDROID_ROOT="y" |
| 252 | shift |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 253 | elif [ "x$1" = "x--runtime-extracted-zipapex" ]; then |
| 254 | shift |
| 255 | USE_EXTRACTED_ZIPAPEX="y" |
| 256 | EXTRACTED_ZIPAPEX_LOC="$1" |
| 257 | shift |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 258 | elif [ "x$1" = "x--runtime-zipapex" ]; then |
| 259 | shift |
| 260 | USE_ZIPAPEX="y" |
| 261 | ZIPAPEX_LOC="$1" |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 262 | # TODO (b/119942078): Currently apex does not support |
| 263 | # symlink_preferred_arch so we will not have a dex2oatd to execute and |
| 264 | # need to manually provide |
| 265 | # dex2oatd64. |
| 266 | DEX2OAT_DEBUG_BINARY="dex2oatd64" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 267 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 268 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 269 | PREBUILD="n" |
| 270 | shift |
| 271 | elif [ "x$1" = "x--no-image" ]; then |
| 272 | HAVE_IMAGE="n" |
| 273 | shift |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 274 | elif [ "x$1" = "x--secondary" ]; then |
| 275 | SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar" |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 276 | # Enable cfg-append to make sure we get the dump for both dex files. |
| 277 | # (otherwise the runtime compilation of the secondary dex will overwrite |
Roland Levillain | b0103ca | 2016-11-01 14:48:47 +0000 | [diff] [blame] | 278 | # the dump of the first one). |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 279 | FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append" |
| 280 | COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 281 | shift |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 282 | elif [ "x$1" = "x--with-agent" ]; then |
| 283 | shift |
| 284 | USE_JVMTI="y" |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 285 | WITH_AGENT+=("$1") |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 286 | shift |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 287 | elif [ "x$1" = "x--debug-wrap-agent" ]; then |
| 288 | WRAP_DEBUGGER_AGENT="y" |
| 289 | shift |
| 290 | elif [ "x$1" = "x--debug-agent" ]; then |
| 291 | shift |
| 292 | DEBUGGER="agent" |
| 293 | USE_JVMTI="y" |
| 294 | DEBUGGER_AGENT="$1" |
| 295 | TIME_OUT="n" |
| 296 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 297 | elif [ "x$1" = "x--debug" ]; then |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 298 | USE_JVMTI="y" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 299 | DEBUGGER="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 300 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 301 | shift |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 302 | elif [ "x$1" = "x--gdbserver-port" ]; then |
| 303 | shift |
| 304 | GDBSERVER_PORT=$1 |
| 305 | shift |
| 306 | elif [ "x$1" = "x--gdbserver-bin" ]; then |
| 307 | shift |
| 308 | GDBSERVER_HOST=$1 |
| 309 | GDBSERVER_DEVICE=$1 |
| 310 | shift |
| 311 | elif [ "x$1" = "x--gdbserver" ]; then |
| 312 | USE_GDBSERVER="y" |
| 313 | DEV_MODE="y" |
| 314 | TIME_OUT="n" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 315 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 316 | elif [ "x$1" = "x--gdb" ]; then |
| 317 | USE_GDB="y" |
| 318 | DEV_MODE="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 319 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 320 | shift |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 321 | elif [ "x$1" = "x--gdb-arg" ]; then |
| 322 | shift |
| 323 | gdb_arg="$1" |
| 324 | GDB_ARGS="${GDB_ARGS} $gdb_arg" |
| 325 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 326 | elif [ "x$1" = "x--zygote" ]; then |
| 327 | ZYGOTE="-Xzygote" |
| 328 | msg "Spawning from zygote" |
| 329 | shift |
| 330 | elif [ "x$1" = "x--dev" ]; then |
| 331 | DEV_MODE="y" |
| 332 | shift |
| 333 | elif [ "x$1" = "x--interpreter" ]; then |
| 334 | INTERPRETER="y" |
| 335 | shift |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 336 | elif [ "x$1" = "x--jit" ]; then |
| 337 | JIT="y" |
| 338 | shift |
Nicolas Geoffray | acc56ac | 2018-10-09 08:45:24 +0100 | [diff] [blame] | 339 | elif [ "x$1" = "x--baseline" ]; then |
| 340 | FLAGS="${FLAGS} -Xcompiler-option --baseline" |
Nicolas Geoffray | 9b195cc | 2019-04-02 08:29:00 +0100 | [diff] [blame] | 341 | COMPILE_FLAGS="${COMPILE_FLAGS} --baseline" |
Nicolas Geoffray | acc56ac | 2018-10-09 08:45:24 +0100 | [diff] [blame] | 342 | shift |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 343 | elif [ "x$1" = "x--jvm" ]; then |
| 344 | USE_JVM="y" |
| 345 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 346 | elif [ "x$1" = "x--invoke-with" ]; then |
| 347 | shift |
| 348 | if [ "x$1" = "x" ]; then |
| 349 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 350 | exit 1 |
| 351 | fi |
| 352 | if [ "x$INVOKE_WITH" = "x" ]; then |
| 353 | INVOKE_WITH="$1" |
| 354 | else |
| 355 | INVOKE_WITH="$INVOKE_WITH $1" |
| 356 | fi |
| 357 | shift |
| 358 | elif [ "x$1" = "x--no-verify" ]; then |
| 359 | VERIFY="n" |
| 360 | shift |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 361 | elif [ "x$1" = "x--verify-soft-fail" ]; then |
| 362 | VERIFY="s" |
| 363 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 364 | elif [ "x$1" = "x--no-optimize" ]; then |
| 365 | OPTIMIZE="n" |
| 366 | shift |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 367 | elif [ "x$1" = "x--chroot" ]; then |
| 368 | shift |
| 369 | CHROOT="$1" |
| 370 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 371 | elif [ "x$1" = "x--android-root" ]; then |
| 372 | shift |
| 373 | ANDROID_ROOT="$1" |
| 374 | shift |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 375 | elif [ "x$1" = "x--android-i18n-root" ]; then |
| 376 | shift |
| 377 | ANDROID_I18N_ROOT="$1" |
| 378 | shift |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 379 | elif [ "x$1" = "x--android-art-root" ]; then |
Roland Levillain | 2807614 | 2019-01-10 16:39:25 +0000 | [diff] [blame] | 380 | shift |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 381 | ANDROID_ART_ROOT="$1" |
Roland Levillain | 2807614 | 2019-01-10 16:39:25 +0000 | [diff] [blame] | 382 | shift |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 383 | elif [ "x$1" = "x--android-tzdata-root" ]; then |
| 384 | shift |
| 385 | ANDROID_TZDATA_ROOT="$1" |
| 386 | shift |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 387 | elif [ "x$1" = "x--instruction-set-features" ]; then |
| 388 | shift |
| 389 | INSTRUCTION_SET_FEATURES="$1" |
| 390 | shift |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 391 | elif [ "x$1" = "x--timeout" ]; then |
| 392 | shift |
| 393 | TIME_OUT_VALUE="$1" |
| 394 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 395 | elif [ "x$1" = "x--" ]; then |
| 396 | shift |
| 397 | break |
| 398 | elif [ "x$1" = "x--64" ]; then |
| 399 | ISA="x86_64" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 400 | GDBSERVER_DEVICE="gdbserver64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 401 | DALVIKVM="dalvikvm64" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 402 | LIBRARY_DIRECTORY="lib64" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 403 | TEST_DIRECTORY="nativetest64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 404 | ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 405 | GET_DEVICE_ISA_BITNESS_FLAG="--64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 406 | shift |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 407 | elif [ "x$1" = "x--experimental" ]; then |
| 408 | if [ "$#" -lt 2 ]; then |
| 409 | echo "missing --experimental option" 1>&2 |
| 410 | exit 1 |
| 411 | fi |
| 412 | EXPERIMENTAL="$EXPERIMENTAL $2" |
| 413 | shift 2 |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 414 | elif [ "x$1" = "x--external-log-tags" ]; then |
| 415 | EXTERNAL_LOG_TAGS="y" |
| 416 | shift |
| 417 | elif [ "x$1" = "x--dry-run" ]; then |
| 418 | DRY_RUN="y" |
| 419 | shift |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 420 | elif [ "x$1" = "x--vdex" ]; then |
| 421 | TEST_VDEX="y" |
| 422 | shift |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 423 | elif [ "x$1" = "x--dm" ]; then |
| 424 | TEST_DM="y" |
| 425 | shift |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 426 | elif [ "x$1" = "x--vdex-filter" ]; then |
| 427 | shift |
| 428 | option="$1" |
David Brazdil | feb2282 | 2019-02-13 21:25:57 +0000 | [diff] [blame] | 429 | VDEX_ARGS="${VDEX_ARGS} --compiler-filter=$option" |
| 430 | shift |
| 431 | elif [ "x$1" = "x--vdex-arg" ]; then |
| 432 | shift |
| 433 | VDEX_ARGS="${VDEX_ARGS} $1" |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 434 | shift |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 435 | elif [ "x$1" = "x--sync" ]; then |
| 436 | SYNC_BEFORE_RUN="y" |
| 437 | shift |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 438 | elif [ "x$1" = "x--profile" ]; then |
| 439 | PROFILE="y" |
| 440 | shift |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 441 | elif [ "x$1" = "x--random-profile" ]; then |
| 442 | RANDOM_PROFILE="y" |
| 443 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 444 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
| 445 | echo "unknown $0 option: $1" 1>&2 |
| 446 | exit 1 |
| 447 | else |
| 448 | break |
| 449 | fi |
| 450 | done |
| 451 | |
Roland Levillain | b59f5fb | 2020-02-19 16:22:48 +0000 | [diff] [blame] | 452 | # HACK: Force the use of `signal_dumper` on host. |
Roland Levillain | 505e56b | 2019-11-20 08:49:24 +0000 | [diff] [blame] | 453 | if [[ "$HOST" = "y" ]]; then |
| 454 | TIME_OUT="timeout" |
| 455 | fi |
| 456 | |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 457 | # If you change this, update the timeout in testrunner.py as well. |
| 458 | if [ -z "$TIME_OUT_VALUE" ] ; then |
| 459 | # 10 minutes is the default. |
| 460 | TIME_OUT_VALUE=600 |
| 461 | |
| 462 | # For sanitized builds use a larger base. |
| 463 | # TODO: Consider sanitized target builds? |
| 464 | if [ "x$SANITIZE_HOST" != "x" ] ; then |
| 465 | TIME_OUT_VALUE=1500 # 25 minutes. |
| 466 | fi |
| 467 | |
Martin Stjernholm | cb497cf | 2019-09-27 18:42:55 +0100 | [diff] [blame] | 468 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + ${TIME_OUT_EXTRA})) |
Andreas Gampe | 6ad30a2 | 2019-09-12 15:12:36 -0700 | [diff] [blame] | 469 | fi |
| 470 | |
Andreas Gampe | 29bfb0c | 2019-09-12 15:17:43 -0700 | [diff] [blame] | 471 | # Escape hatch for slow hosts or devices. Accept an environment variable as a timeout factor. |
| 472 | if [ ! -z "$ART_TIME_OUT_MULTIPLIER" ] ; then |
Martin Stjernholm | 82e61e9 | 2019-09-30 02:43:18 +0000 | [diff] [blame] | 473 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} * ${ART_TIME_OUT_MULTIPLIER})) |
Andreas Gampe | 29bfb0c | 2019-09-12 15:17:43 -0700 | [diff] [blame] | 474 | fi |
| 475 | |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 476 | # The DEX_LOCATION with the chroot prefix, if any. |
| 477 | CHROOT_DEX_LOCATION="$CHROOT$DEX_LOCATION" |
| 478 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 479 | # If running on device, determine the ISA of the device. |
| 480 | if [ "$HOST" = "n" ]; then |
| 481 | ISA=$("$ANDROID_BUILD_TOP/art/test/utils/get-device-isa" "$GET_DEVICE_ISA_BITNESS_FLAG") |
| 482 | fi |
| 483 | |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 484 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 485 | FLAGS="${FLAGS} ${ANDROID_FLAGS}" |
Alex Light | baac7e4 | 2018-06-08 15:30:11 +0000 | [diff] [blame] | 486 | # we don't want to be trying to get adbconnections since the plugin might |
| 487 | # not have been built. |
| 488 | FLAGS="${FLAGS} -XjdwpProvider:none" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 489 | for feature in ${EXPERIMENTAL}; do |
Alex Light | fa02285 | 2015-10-28 09:13:20 -0700 | [diff] [blame] | 490 | FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 491 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}" |
| 492 | done |
| 493 | fi |
| 494 | |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 495 | if [ "$CREATE_ANDROID_ROOT" = "y" ]; then |
| 496 | ANDROID_ROOT=$DEX_LOCATION/android-root |
| 497 | fi |
| 498 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 499 | if [ "x$1" = "x" ] ; then |
| 500 | MAIN="Main" |
| 501 | else |
| 502 | MAIN="$1" |
Andreas Gampe | f2fdc73 | 2014-06-11 08:20:47 -0700 | [diff] [blame] | 503 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 504 | fi |
| 505 | |
| 506 | if [ "$ZYGOTE" = "" ]; then |
| 507 | if [ "$OPTIMIZE" = "y" ]; then |
| 508 | if [ "$VERIFY" = "y" ]; then |
| 509 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 510 | else |
| 511 | DEX_OPTIMIZE="-Xdexopt:all" |
| 512 | fi |
| 513 | msg "Performing optimizations" |
| 514 | else |
| 515 | DEX_OPTIMIZE="-Xdexopt:none" |
| 516 | msg "Skipping optimizations" |
| 517 | fi |
| 518 | |
| 519 | if [ "$VERIFY" = "y" ]; then |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 520 | JVM_VERIFY_ARG="-Xverify:all" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 521 | msg "Performing verification" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 522 | elif [ "$VERIFY" = "s" ]; then |
| 523 | JVM_VERIFY_ARG="Xverify:all" |
| 524 | DEX_VERIFY="-Xverify:softfail" |
| 525 | msg "Forcing verification to be soft fail" |
| 526 | else # VERIFY = "n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 527 | DEX_VERIFY="-Xverify:none" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 528 | JVM_VERIFY_ARG="-Xverify:none" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 529 | msg "Skipping verification" |
| 530 | fi |
| 531 | fi |
| 532 | |
| 533 | msg "------------------------------" |
| 534 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 535 | if [ "$DEBUGGER" = "y" ]; then |
| 536 | # Use this instead for ddms and connect by running 'ddms': |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 537 | # DEBUGGER_OPTS="-XjdwpOptions=server=y,suspend=y -XjdwpProvider:adbconnection" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 538 | # TODO: add a separate --ddms option? |
| 539 | |
| 540 | PORT=12345 |
| 541 | msg "Waiting for jdb to connect:" |
| 542 | if [ "$HOST" = "n" ]; then |
| 543 | msg " adb forward tcp:$PORT tcp:$PORT" |
| 544 | fi |
| 545 | msg " jdb -attach localhost:$PORT" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 546 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | fc58809 | 2020-01-23 15:39:08 -0800 | [diff] [blame] | 547 | # Use the default libjdwp agent. Use --debug-agent to use a custom one. |
| 548 | DEBUGGER_OPTS="-agentpath:libjdwp.so=transport=dt_socket,address=$PORT,server=y,suspend=y -XjdwpProvider:internal" |
Alex Light | 264a486 | 2018-01-31 16:47:58 +0000 | [diff] [blame] | 549 | else |
| 550 | DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 551 | fi |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 552 | elif [ "$DEBUGGER" = "agent" ]; then |
| 553 | PORT=12345 |
| 554 | # TODO Support ddms connection and support target. |
| 555 | if [ "$HOST" = "n" ]; then |
| 556 | echo "--debug-agent not supported yet for target!" |
| 557 | exit 1 |
| 558 | fi |
| 559 | AGENTPATH=${DEBUGGER_AGENT} |
| 560 | if [ "$WRAP_DEBUGGER_AGENT" = "y" ]; then |
| 561 | WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentpropertiesd.so" |
| 562 | if [ "$TEST_IS_NDEBUG" = "y" ]; then |
| 563 | WRAPPROPS="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}/libwrapagentproperties.so" |
| 564 | fi |
| 565 | AGENTPATH="${WRAPPROPS}=${ANDROID_BUILD_TOP}/art/tools/libjdwp-compat.props,${AGENTPATH}" |
| 566 | fi |
| 567 | msg "Connect to localhost:$PORT" |
| 568 | DEBUGGER_OPTS="-agentpath:${AGENTPATH}=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 569 | fi |
| 570 | |
Alex Light | 54dabfb | 2018-09-19 16:29:09 -0700 | [diff] [blame] | 571 | for agent in "${WITH_AGENT[@]}"; do |
| 572 | FLAGS="${FLAGS} -agentpath:${agent}" |
| 573 | done |
Alex Light | 0e151e7 | 2017-10-25 10:50:35 -0700 | [diff] [blame] | 574 | |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 575 | if [ "$USE_JVMTI" = "y" ]; then |
| 576 | if [ "$USE_JVM" = "n" ]; then |
| 577 | plugin=libopenjdkjvmtid.so |
| 578 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 579 | plugin=libopenjdkjvmti.so |
| 580 | fi |
Alex Light | 2ce6fc8 | 2017-12-18 16:42:36 -0800 | [diff] [blame] | 581 | # We used to add flags here that made the runtime debuggable but that is not |
| 582 | # needed anymore since the plugin can do it for us now. |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 583 | FLAGS="${FLAGS} -Xplugin:${plugin}" |
Alex Light | c281ba5 | 2017-10-11 11:35:55 -0700 | [diff] [blame] | 584 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 585 | fi |
| 586 | |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 587 | if [ "$IS_JVMTI_TEST" = "y" ]; then |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 588 | agent=libtiagentd.so |
| 589 | lib=tiagentd |
| 590 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 591 | agent=libtiagent.so |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 592 | lib=tiagent |
| 593 | fi |
| 594 | |
| 595 | ARGS="${ARGS} ${lib}" |
| 596 | if [[ "$USE_JVM" = "y" ]]; then |
| 597 | FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${TEST_NAME},jvm" |
| 598 | else |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 599 | if [[ "$HOST" = "y" ]]; then |
| 600 | FLAGS="${FLAGS} -agentpath:${agent}=${TEST_NAME},art" |
| 601 | else |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 602 | # The linker configuration used for dalvikvm(64) in the ART APEX |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 603 | # requires us to pass the full path to the agent to the runtime when |
| 604 | # running on device. |
| 605 | FLAGS="${FLAGS} -agentpath:/data/${TEST_DIRECTORY}/art/${ISA}/${agent}=${TEST_NAME},art" |
| 606 | fi |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 607 | fi |
| 608 | fi |
| 609 | |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 610 | if [[ "$JVMTI_STRESS" = "y" ]]; then |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 611 | agent=libtistressd.so |
| 612 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 613 | agent=libtistress.so |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 614 | fi |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 615 | |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 616 | # Just give it a default start so we can always add ',' to it. |
| 617 | agent_args="jvmti-stress" |
| 618 | if [[ "$JVMTI_REDEFINE_STRESS" = "y" ]]; then |
| 619 | # We really cannot do this on RI so don't both passing it in that case. |
| 620 | if [[ "$USE_JVM" = "n" ]]; then |
Alex Light | ceae954 | 2017-09-07 13:28:00 -0700 | [diff] [blame] | 621 | agent_args="${agent_args},redefine" |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 622 | fi |
| 623 | fi |
Alex Light | 43e935d | 2017-06-19 15:40:40 -0700 | [diff] [blame] | 624 | if [[ "$JVMTI_FIELD_STRESS" = "y" ]]; then |
| 625 | agent_args="${agent_args},field" |
| 626 | fi |
Alex Light | c38c369 | 2017-06-27 15:45:14 -0700 | [diff] [blame] | 627 | if [[ "$JVMTI_STEP_STRESS" = "y" ]]; then |
| 628 | agent_args="${agent_args},step" |
| 629 | fi |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 630 | if [[ "$JVMTI_TRACE_STRESS" = "y" ]]; then |
| 631 | agent_args="${agent_args},trace" |
| 632 | fi |
| 633 | # In the future add onto this; |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 634 | if [[ "$USE_JVM" = "y" ]]; then |
Alex Light | b7edcda | 2017-04-27 13:20:31 -0700 | [diff] [blame] | 635 | FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${agent_args}" |
Alex Light | 42151c0 | 2017-04-20 15:54:25 -0700 | [diff] [blame] | 636 | else |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 637 | if [[ "$HOST" = "y" ]]; then |
| 638 | FLAGS="${FLAGS} -agentpath:${agent}=${agent_args}" |
| 639 | else |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 640 | # The linker configuration used for dalvikvm(64) in the ART APEX |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 641 | # requires us to pass the full path to the agent to the runtime when |
| 642 | # running on device. |
| 643 | FLAGS="${FLAGS} -agentpath:/data/${TEST_DIRECTORY}/art/${ISA}/${agent}=${agent_args}" |
| 644 | fi |
Alex Light | 8f2c6d4 | 2017-04-10 16:27:35 -0700 | [diff] [blame] | 645 | fi |
| 646 | fi |
| 647 | |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 648 | if [ "$USE_JVM" = "y" ]; then |
Alex Light | 9c20a14 | 2016-08-23 15:05:12 -0700 | [diff] [blame] | 649 | export LD_LIBRARY_PATH=${ANDROID_HOST_OUT}/lib64 |
Alex Light | 47d49b8 | 2017-07-25 14:06:34 -0700 | [diff] [blame] | 650 | # Some jvmti tests are flaky without -Xint on the RI. |
| 651 | if [ "$IS_JVMTI_TEST" = "y" ]; then |
| 652 | FLAGS="${FLAGS} -Xint" |
| 653 | fi |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 654 | # Xmx is necessary since we don't pass down the ART flags to JVM. |
Vladimir Marko | c5798bf | 2016-12-09 10:20:54 +0000 | [diff] [blame] | 655 | # We pass the classes2 path whether it's used (src-multidex) or not. |
| 656 | cmdline="${JAVA} ${DEBUGGER_OPTS} ${JVM_VERIFY_ARG} -Xmx256m -classpath classes:classes2 ${FLAGS} $MAIN $@ ${ARGS}" |
Andreas Gampe | 3f1dc56 | 2015-05-18 15:52:22 -0700 | [diff] [blame] | 657 | if [ "$DEV_MODE" = "y" ]; then |
| 658 | echo $cmdline |
| 659 | fi |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 660 | if [ "$CREATE_RUNNER" = "y" ]; then |
| 661 | echo "#!/bin/bash" > runit.sh |
| 662 | echo "export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" |
| 663 | echo $cmdline "2>&1" >> runit.sh |
| 664 | chmod u+x runit.sh |
| 665 | echo "Runnable test script written to $PWD/runit.sh" |
| 666 | else |
| 667 | $cmdline |
| 668 | fi |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 669 | exit |
| 670 | fi |
| 671 | |
Vladimir Marko | 0ace563 | 2018-12-14 11:11:47 +0000 | [diff] [blame] | 672 | # Note: This must start with the CORE_IMG_JARS in Android.common_path.mk |
| 673 | # because that's what we use for compiling the core.art image. |
| 674 | # It may contain additional modules from TEST_CORE_JARS. |
Victor Chang | 759845f | 2019-08-06 16:04:36 +0100 | [diff] [blame] | 675 | bpath_modules="core-oj core-libart core-icu4j okhttp bouncycastle apache-xml conscrypt" |
Vladimir Marko | 7a85e70 | 2018-12-03 18:47:23 +0000 | [diff] [blame] | 676 | if [ "${HOST}" = "y" ]; then |
| 677 | framework="${ANDROID_HOST_OUT}/framework" |
| 678 | if [ "${ANDROID_HOST_OUT:0:${#ANDROID_BUILD_TOP}+1}" = "${ANDROID_BUILD_TOP}/" ]; then |
| 679 | framework_location="${ANDROID_HOST_OUT:${#ANDROID_BUILD_TOP}+1}/framework" |
| 680 | else |
| 681 | echo "error: ANDROID_BUILD_TOP/ is not a prefix of ANDROID_HOST_OUT" |
| 682 | echo "ANDROID_BUILD_TOP=${ANDROID_BUILD_TOP}" |
| 683 | echo "ANDROID_HOST_OUT=${ANDROID_HOST_OUT}" |
| 684 | exit |
| 685 | fi |
| 686 | bpath_suffix="-hostdex" |
| 687 | else |
| 688 | framework="${ANDROID_ROOT}/framework" |
| 689 | framework_location="${ANDROID_ROOT}/framework" |
| 690 | bpath_suffix="-testdex" |
| 691 | fi |
| 692 | bpath="" |
| 693 | bpath_locations="" |
| 694 | bpath_separator="" |
| 695 | for bpath_module in ${bpath_modules}; do |
| 696 | bpath+="${bpath_separator}${framework}/${bpath_module}${bpath_suffix}.jar" |
| 697 | bpath_locations+="${bpath_separator}${framework_location}/${bpath_module}${bpath_suffix}.jar" |
| 698 | bpath_separator=":" |
| 699 | done |
| 700 | # Pass down the bootclasspath |
| 701 | FLAGS="${FLAGS} -Xbootclasspath:${bpath}" |
| 702 | FLAGS="${FLAGS} -Xbootclasspath-locations:${bpath_locations}" |
| 703 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xbootclasspath:${bpath}" |
| 704 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xbootclasspath-locations:${bpath_locations}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 705 | |
| 706 | if [ "$HAVE_IMAGE" = "n" ]; then |
Andreas Gampe | 1078d15 | 2017-11-07 18:00:54 -0800 | [diff] [blame] | 707 | # Disable image dex2oat - this will forbid the runtime to patch or compile an image. |
| 708 | FLAGS="${FLAGS} -Xnoimage-dex2oat" |
| 709 | |
| 710 | # We'll abuse a second flag here to test different behavior. If --relocate, use the |
| 711 | # existing image - relocation will fail as patching is disallowed. If --no-relocate, |
| 712 | # pass a non-existent image - compilation will fail as dex2oat is disallowed. |
| 713 | if [ "${RELOCATE}" = "y" ] ; then |
| 714 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
| 715 | else |
Roland Levillain | ef01222 | 2017-06-21 16:28:06 +0100 | [diff] [blame] | 716 | DALVIKVM_BOOT_OPT="-Ximage:/system/non-existent/core.art" |
Andreas Gampe | 1078d15 | 2017-11-07 18:00:54 -0800 | [diff] [blame] | 717 | fi |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 718 | else |
| 719 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 720 | fi |
| 721 | |
| 722 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 723 | if [ "$USE_GDB" = "y" ]; then |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 724 | if [ "$USE_GDBSERVER" = "y" ]; then |
| 725 | echo "Cannot pass both --gdb and --gdbserver at the same time!" >&2 |
| 726 | exit 1 |
| 727 | elif [ "$HOST" = "n" ]; then |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 728 | # We might not have any hostname resolution if we are using a chroot. |
| 729 | GDB="$GDBSERVER_DEVICE --no-startup-with-shell 127.0.0.1$GDBSERVER_PORT" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 730 | else |
| 731 | if [ `uname` = "Darwin" ]; then |
| 732 | GDB=lldb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 733 | GDB_ARGS="$GDB_ARGS -- $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 734 | DALVIKVM= |
| 735 | else |
| 736 | GDB=gdb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 737 | GDB_ARGS="$GDB_ARGS --args $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 738 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 739 | # gdbargs="--annotate=3 $gdbargs" |
| 740 | fi |
| 741 | fi |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 742 | elif [ "$USE_GDBSERVER" = "y" ]; then |
| 743 | if [ "$HOST" = "n" ]; then |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 744 | # We might not have any hostname resolution if we are using a chroot. |
| 745 | GDB="$GDBSERVER_DEVICE --no-startup-with-shell 127.0.0.1$GDBSERVER_PORT" |
| 746 | else |
| 747 | GDB="$GDBSERVER_HOST $GDBSERVER_PORT" |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 748 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 749 | fi |
| 750 | |
| 751 | if [ "$INTERPRETER" = "y" ]; then |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 752 | INT_OPTS="${INT_OPTS} -Xint" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 753 | if [ "$VERIFY" = "y" ] ; then |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 754 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=quicken" |
| 755 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=quicken" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 756 | elif [ "$VERIFY" = "s" ]; then |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 757 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=extract" |
| 758 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=extract" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 759 | DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail" |
| 760 | else # VERIFY = "n" |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 761 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=assume-verified" |
| 762 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=assume-verified" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 763 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 764 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 765 | fi |
| 766 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 767 | if [ "$JIT" = "y" ]; then |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 768 | INT_OPTS="${INT_OPTS} -Xusejit:true" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 769 | if [ "$VERIFY" = "y" ] ; then |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 770 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=quicken" |
| 771 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=quicken" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 772 | else |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame] | 773 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=assume-verified" |
| 774 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=assume-verified" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 775 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 776 | fi |
Nicolas Geoffray | a5ca8eb | 2018-08-24 13:39:13 +0100 | [diff] [blame] | 777 | else |
| 778 | INT_OPTS="${INT_OPTS} -Xusejit:false" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 779 | fi |
| 780 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 781 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
| 782 | |
Richard Uhler | 020c0f3 | 2017-03-14 16:23:17 +0000 | [diff] [blame] | 783 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 784 | if [ "$RELOCATE" = "y" ]; then |
Richard Uhler | c52f303 | 2017-03-02 13:45:45 +0000 | [diff] [blame] | 785 | FLAGS="${FLAGS} -Xrelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 786 | else |
| 787 | FLAGS="$FLAGS -Xnorelocate" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 788 | fi |
| 789 | |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 790 | if [ "$BIONIC" = "y" ]; then |
| 791 | # This is the location that soong drops linux_bionic builds. Despite being |
| 792 | # called linux_bionic-x86 the build is actually amd64 (x86_64) only. |
| 793 | if [ ! -e "$OUT_DIR/soong/host/linux_bionic-x86" ]; then |
| 794 | echo "linux_bionic-x86 target doesn't seem to have been built!" >&2 |
| 795 | exit 1 |
| 796 | fi |
Andreas Gampe | 148c160 | 2019-06-10 16:47:46 -0700 | [diff] [blame] | 797 | # Set TIMEOUT_DUMPER manually so it works even with apex's |
| 798 | TIMEOUT_DUMPER=$OUT_DIR/soong/host/linux_bionic-x86/bin/signal_dumper |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 799 | fi |
| 800 | |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 801 | # Prevent test from silently falling back to interpreter in no-prebuild mode. This happens |
| 802 | # when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking |
| 803 | # full path to dex, stripping leading '/', appending '@classes.vdex' and changing every |
| 804 | # remaining '/' into '@'. |
| 805 | if [ "$HOST" = "y" ]; then |
| 806 | max_filename_size=$(getconf NAME_MAX $DEX_LOCATION) |
| 807 | else |
Roland Levillain | 2ae376f | 2018-01-30 11:35:11 +0000 | [diff] [blame] | 808 | # There is no getconf on device, fallback to standard value. |
| 809 | # See NAME_MAX in kernel <linux/limits.h> |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 810 | max_filename_size=255 |
| 811 | fi |
| 812 | # Compute VDEX_NAME. |
| 813 | DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}" |
| 814 | VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex" |
| 815 | if [ ${#VDEX_NAME} -gt $max_filename_size ]; then |
Nicolas Geoffray | bea3e31 | 2017-03-07 09:59:05 +0000 | [diff] [blame] | 816 | echo "Dex location path too long:" |
| 817 | echo "$VDEX_NAME is ${#VDEX_NAME} character long, and the limit is $max_filename_size." |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 818 | exit 1 |
| 819 | fi |
| 820 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 821 | if [ "$HOST" = "y" ]; then |
| 822 | # On host, run binaries (`dex2oat(d)`, `dalvikvm`, `profman`) from the `bin` |
| 823 | # directory under the "Android Root" (usually `out/host/linux-x86`). |
| 824 | # |
| 825 | # TODO(b/130295968): Adjust this if/when ART host artifacts are installed |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 826 | # under the ART root (usually `out/host/linux-x86/com.android.art`). |
| 827 | ANDROID_ART_BIN_DIR=$ANDROID_ROOT/bin |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 828 | else |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 829 | # On target, run binaries (`dex2oat(d)`, `dalvikvm`, `profman`) from the ART |
| 830 | # APEX's `bin` directory. This means the linker will observe the ART APEX |
| 831 | # linker configuration file (`/apex/com.android.art/etc/ld.config.txt`) for |
| 832 | # these binaries. |
| 833 | ANDROID_ART_BIN_DIR=$ANDROID_ART_ROOT/bin |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 834 | fi |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 835 | |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 836 | profman_cmdline="true" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 837 | dex2oat_cmdline="true" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 838 | vdex_cmdline="true" |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 839 | dm_cmdline="true" |
Andreas Gampe | b09abb2 | 2018-05-03 11:51:22 -0700 | [diff] [blame] | 840 | mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 841 | strip_cmdline="true" |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 842 | sync_cmdline="true" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 843 | linkroot_cmdline="true" |
| 844 | linkroot_overlay_cmdline="true" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 845 | setupapex_cmdline="true" |
| 846 | installapex_cmdline="true" |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 847 | |
| 848 | linkdirs() { |
| 849 | find "$1" -maxdepth 1 -mindepth 1 -type d | xargs -i ln -sf '{}' "$2" |
| 850 | } |
| 851 | |
| 852 | if [ "$CREATE_ANDROID_ROOT" = "y" ]; then |
| 853 | mkdir_locations="${mkdir_locations} ${ANDROID_ROOT}" |
| 854 | linkroot_cmdline="linkdirs ${ANDROID_HOST_OUT} ${ANDROID_ROOT}" |
| 855 | if [ "${BIONIC}" = "y" ]; then |
| 856 | # TODO Make this overlay more generic. |
| 857 | linkroot_overlay_cmdline="linkdirs $OUT_DIR/soong/host/linux_bionic-x86 ${ANDROID_ROOT}" |
| 858 | fi |
| 859 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 860 | |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 861 | if [ "$USE_ZIPAPEX" = "y" ]; then |
| 862 | # TODO Currently this only works for linux_bionic zipapexes because those are |
| 863 | # stripped and so small enough that the ulimit doesn't kill us. |
| 864 | mkdir_locations="${mkdir_locations} $DEX_LOCATION/zipapex" |
| 865 | zip_options="-qq" |
| 866 | if [ "$DEV_MODE" = "y" ]; then |
| 867 | zip_options="" |
| 868 | fi |
Alex Light | fc52ffc | 2019-01-31 15:48:18 -0800 | [diff] [blame] | 869 | setupapex_cmdline="unzip -o -u ${zip_options} ${ZIPAPEX_LOC} apex_payload.zip -d ${DEX_LOCATION}" |
| 870 | installapex_cmdline="unzip -o -u ${zip_options} ${DEX_LOCATION}/apex_payload.zip -d ${DEX_LOCATION}/zipapex" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 871 | ANDROID_ART_BIN_DIR=$DEX_LOCATION/zipapex/bin |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 872 | elif [ "$USE_EXTRACTED_ZIPAPEX" = "y" ]; then |
| 873 | # Just symlink the zipapex binaries |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 874 | ANDROID_ART_BIN_DIR=$DEX_LOCATION/zipapex/bin |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 875 | # Force since some tests manually run this file twice. |
| 876 | ln_options="" |
| 877 | if [ "$DEV_MODE" = "y" ]; then |
| 878 | ln_options="--verbose" |
| 879 | fi |
| 880 | installapex_cmdline="ln -s -f ${ln_options} ${EXTRACTED_ZIPAPEX_LOC} ${DEX_LOCATION}/zipapex" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 881 | fi |
| 882 | |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 883 | # PROFILE takes precedence over RANDOM_PROFILE, since PROFILE tests require a |
| 884 | # specific profile to run properly. |
| 885 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 886 | profman_cmdline="$ANDROID_ART_BIN_DIR/profman \ |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 887 | --apk=$DEX_LOCATION/$TEST_NAME.jar \ |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 888 | --dex-location=$DEX_LOCATION/$TEST_NAME.jar" |
Calin Juravle | 6df62f7 | 2017-04-28 19:58:01 -0700 | [diff] [blame] | 889 | if [ -f $DEX_LOCATION/$TEST_NAME-ex.jar ]; then |
| 890 | profman_cmdline="${profman_cmdline} \ |
| 891 | --apk=$DEX_LOCATION/$TEST_NAME-ex.jar \ |
| 892 | --dex-location=$DEX_LOCATION/$TEST_NAME-ex.jar" |
| 893 | fi |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 894 | COMPILE_FLAGS="${COMPILE_FLAGS} --profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
| 895 | FLAGS="${FLAGS} -Xcompiler-option --profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 896 | if [ "$PROFILE" = "y" ]; then |
| 897 | profman_cmdline="${profman_cmdline} --create-profile-from=$DEX_LOCATION/profile \ |
| 898 | --reference-profile-file=$DEX_LOCATION/$TEST_NAME.prof" |
| 899 | else |
| 900 | profman_cmdline="${profman_cmdline} --generate-test-profile=$DEX_LOCATION/$TEST_NAME.prof \ |
| 901 | --generate-test-profile-seed=0" |
| 902 | fi |
Nicolas Geoffray | 0b6a638 | 2017-03-10 09:38:35 +0000 | [diff] [blame] | 903 | fi |
| 904 | |
David Srbecky | b0ec679 | 2020-02-06 20:18:17 +0000 | [diff] [blame] | 905 | # Enable mini-debug-info for JIT (if JIT is used). |
| 906 | FLAGS="$FLAGS -Xcompiler-option --generate-mini-debug-info" |
| 907 | |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 908 | if [ "$PREBUILD" = "y" ]; then |
| 909 | mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA" |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 910 | if [ "$APP_IMAGE" = "y" ]; then |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 911 | # Pick a base that will force the app image to get relocated. |
| 912 | app_image="--app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art --resolve-startup-const-strings=true" |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 913 | fi |
| 914 | |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 915 | dex2oat_binary=${DEX2OAT_DEBUG_BINARY} |
Roland Levillain | 6c3af16 | 2017-04-27 11:18:56 +0100 | [diff] [blame] | 916 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
Alex Light | 907001d | 2019-01-17 00:16:04 +0000 | [diff] [blame] | 917 | dex2oat_binary=${DEX2OAT_NDEBUG_BINARY} |
Roland Levillain | 6c3af16 | 2017-04-27 11:18:56 +0100 | [diff] [blame] | 918 | fi |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 919 | dex2oat_cmdline="$INVOKE_WITH $ANDROID_ART_BIN_DIR/$dex2oat_binary \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 920 | $COMPILE_FLAGS \ |
Nicolas Geoffray | 68e25eb | 2014-10-29 23:02:11 +0000 | [diff] [blame] | 921 | --boot-image=${BOOT_IMAGE} \ |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 922 | --dex-file=$DEX_LOCATION/$TEST_NAME.jar \ |
| 923 | --oat-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.odex \ |
| 924 | ${app_image} \ |
David Srbecky | 87712da | 2020-01-17 15:50:02 +0000 | [diff] [blame] | 925 | --generate-mini-debug-info \ |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 926 | --instruction-set=$ISA" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 927 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 928 | dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
| 929 | fi |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 930 | |
| 931 | # Add in a timeout. This is important for testing the compilation/verification time of |
| 932 | # pathological cases. |
| 933 | # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for |
| 934 | # now. We should try to improve this. |
| 935 | # The current value is rather arbitrary. run-tests should compile quickly. |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 936 | # Watchdog timeout is in milliseconds so add 3 '0's to the dex2oat timeout. |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 937 | if [ "$HOST" != "n" ]; then |
| 938 | # Use SIGRTMIN+2 to try to dump threads. |
| 939 | # Use -k 1m to SIGKILL it a minute later if it hasn't ended. |
Alex Light | 483208d | 2017-09-26 09:31:17 -0700 | [diff] [blame] | 940 | dex2oat_cmdline="timeout -k ${DEX2OAT_TIMEOUT}s -s SIGRTMIN+2 ${DEX2OAT_RT_TIMEOUT}s ${dex2oat_cmdline} --watchdog-timeout=${DEX2OAT_TIMEOUT}000" |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 941 | fi |
Nicolas Geoffray | fbc4f11 | 2017-04-27 21:45:35 +0100 | [diff] [blame] | 942 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 943 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex --output-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex" |
Nicolas Geoffray | fbc4f11 | 2017-04-27 21:45:35 +0100 | [diff] [blame] | 944 | elif [ "$TEST_VDEX" = "y" ]; then |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 945 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex" |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 946 | elif [ "$TEST_DM" = "y" ]; then |
| 947 | dex2oat_cmdline="${dex2oat_cmdline} --output-vdex=$DEX_LOCATION/oat/$ISA/primary.vdex" |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 948 | dm_cmdline="zip -qj $DEX_LOCATION/oat/$ISA/$TEST_NAME.dm $DEX_LOCATION/oat/$ISA/primary.vdex" |
| 949 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_ARGS} --dump-timings --dm-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.dm" |
| 950 | elif [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
| 951 | vdex_cmdline="${dex2oat_cmdline} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex --output-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 952 | fi |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 953 | fi |
| 954 | |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 955 | if [ "$STRIP_DEX" = "y" ]; then |
| 956 | strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex" |
| 957 | fi |
| 958 | |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 959 | if [ "$SYNC_BEFORE_RUN" = "y" ]; then |
| 960 | sync_cmdline="sync" |
| 961 | fi |
| 962 | |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 963 | DALVIKVM_ISA_FEATURES_ARGS="" |
| 964 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 965 | DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 966 | fi |
| 967 | |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 968 | # java.io.tmpdir can only be set at launch time. |
| 969 | TMP_DIR_OPTION="" |
| 970 | if [ "$HOST" = "n" ]; then |
| 971 | TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp" |
| 972 | fi |
| 973 | |
Alex Light | b801210 | 2019-11-13 01:41:04 +0000 | [diff] [blame] | 974 | # The build servers have an ancient version of bash so we cannot use @Q. |
| 975 | if [ "$USE_GDBSERVER" == "y" ]; then |
| 976 | printf -v QUOTED_DALVIKVM_BOOT_OPT "%q" "$DALVIKVM_BOOT_OPT" |
| 977 | else |
| 978 | QUOTED_DALVIKVM_BOOT_OPT="$DALVIKVM_BOOT_OPT" |
| 979 | fi |
| 980 | |
Nicolas Geoffray | 6ee4971 | 2018-03-30 14:39:05 +0000 | [diff] [blame] | 981 | # We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind. |
| 982 | # b/27185632 |
| 983 | # b/24664297 |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 984 | dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ART_BIN_DIR/$DALVIKVM \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 985 | $GDB_ARGS \ |
| 986 | $FLAGS \ |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 987 | $DEX_VERIFY \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 988 | -XXlib:$LIB \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 989 | $DEX2OAT \ |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 990 | $DALVIKVM_ISA_FEATURES_ARGS \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 991 | $ZYGOTE \ |
| 992 | $JNI_OPTS \ |
| 993 | $INT_OPTS \ |
| 994 | $DEBUGGER_OPTS \ |
Alex Light | b801210 | 2019-11-13 01:41:04 +0000 | [diff] [blame] | 995 | ${QUOTED_DALVIKVM_BOOT_OPT} \ |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 996 | $TMP_DIR_OPTION \ |
Nicolas Geoffray | 6ee4971 | 2018-03-30 14:39:05 +0000 | [diff] [blame] | 997 | -XX:DumpNativeStackOnSigQuit:false \ |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 998 | -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 999 | |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 1000 | # Remove whitespace. |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 1001 | dex2oat_cmdline=$(echo $dex2oat_cmdline) |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 1002 | dalvikvm_cmdline=$(echo $dalvikvm_cmdline) |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 1003 | dm_cmdline=$(echo $dm_cmdline) |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 1004 | vdex_cmdline=$(echo $vdex_cmdline) |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1005 | profman_cmdline=$(echo $profman_cmdline) |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1006 | |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1007 | # Use an empty ASAN_OPTIONS to enable defaults. |
| 1008 | # Note: this is required as envsetup right now exports detect_leaks=0. |
| 1009 | RUN_TEST_ASAN_OPTIONS="" |
| 1010 | |
Andreas Gampe | 5840839 | 2017-05-16 10:45:46 -0700 | [diff] [blame] | 1011 | # Multiple shutdown leaks. b/38341789 |
| 1012 | if [ "x$RUN_TEST_ASAN_OPTIONS" != "x" ] ; then |
| 1013 | RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}:" |
| 1014 | fi |
| 1015 | RUN_TEST_ASAN_OPTIONS="${RUN_TEST_ASAN_OPTIONS}detect_leaks=0" |
| 1016 | |
Vladimir Marko | a497a39 | 2018-09-26 10:52:50 +0100 | [diff] [blame] | 1017 | # For running, we must turn off logging when dex2oat is missing. Otherwise we use |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1018 | # the same defaults as for prebuilt: everything when --dev, otherwise errors and above only. |
| 1019 | if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then |
| 1020 | if [ "$DEV_MODE" = "y" ]; then |
| 1021 | export ANDROID_LOG_TAGS='*:d' |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1022 | elif [ "$HAVE_IMAGE" = "n" ]; then |
| 1023 | # All tests would log the error of missing image. Be silent here and only log fatal |
| 1024 | # events. |
| 1025 | export ANDROID_LOG_TAGS='*:s' |
| 1026 | else |
| 1027 | # We are interested in LOG(ERROR) output. |
| 1028 | export ANDROID_LOG_TAGS='*:e' |
| 1029 | fi |
| 1030 | fi |
| 1031 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1032 | if [ "$HOST" = "n" ]; then |
| 1033 | adb root > /dev/null |
| 1034 | adb wait-for-device |
| 1035 | if [ "$QUIET" = "n" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1036 | adb shell rm -rf $CHROOT_DEX_LOCATION |
| 1037 | adb shell mkdir -p $CHROOT_DEX_LOCATION |
| 1038 | adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION |
| 1039 | adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 1040 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1041 | adb push profile $CHROOT_DEX_LOCATION |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1042 | fi |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1043 | # Copy resource folder |
| 1044 | if [ -d res ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1045 | adb push res $CHROOT_DEX_LOCATION |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1046 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1047 | else |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1048 | adb shell rm -rf $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1049 | adb shell mkdir -p $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1050 | adb push $TEST_NAME.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
| 1051 | adb push $TEST_NAME-ex.jar $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
Jeff Hao | 002b931 | 2017-03-27 16:23:08 -0700 | [diff] [blame] | 1052 | if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1053 | adb push profile $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1054 | fi |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1055 | # Copy resource folder |
| 1056 | if [ -d res ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1057 | adb push res $CHROOT_DEX_LOCATION >/dev/null 2>&1 |
David Brazdil | 7d2ec61 | 2018-01-19 14:19:59 +0000 | [diff] [blame] | 1058 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1059 | fi |
| 1060 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1061 | # Populate LD_LIBRARY_PATH. |
| 1062 | LD_LIBRARY_PATH= |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1063 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 1064 | # Current default installation is dalvikvm 64bits and dex2oat 32bits, |
| 1065 | # so we can only use LD_LIBRARY_PATH when testing on a local |
| 1066 | # installation. |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1067 | LD_LIBRARY_PATH="$ANDROID_ROOT/$LIBRARY_DIRECTORY" |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1068 | fi |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1069 | # Needed to access libarttest(d).so and JVMTI agent libraries. |
| 1070 | LD_LIBRARY_PATH="/data/$TEST_DIRECTORY/art/$ISA:$LD_LIBRARY_PATH" |
| 1071 | # Needed to access the boot (core) image files. |
| 1072 | LD_LIBRARY_PATH="/data/art-test/$ISA:$LD_LIBRARY_PATH" |
| 1073 | # Needed to access the test's Odex files. |
| 1074 | LD_LIBRARY_PATH="$DEX_LOCATION/oat/$ISA:$LD_LIBRARY_PATH" |
| 1075 | # Needed to access the test's native libraries (see e.g. 674-hiddenapi, |
| 1076 | # which generates `libhiddenapitest_*.so` libraries in `$DEX_LOCATION`). |
| 1077 | LD_LIBRARY_PATH="$DEX_LOCATION:$LD_LIBRARY_PATH" |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 1078 | |
Dimitry Ivanov | 49c2c92 | 2017-02-14 11:06:14 -0800 | [diff] [blame] | 1079 | # System libraries needed by libarttestd.so |
Vladimir Marko | 2da72ed | 2018-03-07 12:58:11 +0000 | [diff] [blame] | 1080 | PUBLIC_LIBS=libc++.so:libbacktrace.so:libbase.so:libnativehelper.so |
| 1081 | if [ "$TEST_IS_NDEBUG" = "y" ]; then |
David Sehr | 1f01016 | 2018-05-15 08:59:32 -0700 | [diff] [blame] | 1082 | PUBLIC_LIBS=$PUBLIC_LIBS:libart.so:libdexfile.so:libprofile.so:libartbase.so |
Vladimir Marko | 2da72ed | 2018-03-07 12:58:11 +0000 | [diff] [blame] | 1083 | else |
David Sehr | 1f01016 | 2018-05-15 08:59:32 -0700 | [diff] [blame] | 1084 | PUBLIC_LIBS=$PUBLIC_LIBS:libartd.so:libdexfiled.so:libprofiled.so:libartbased.so |
Vladimir Marko | 2da72ed | 2018-03-07 12:58:11 +0000 | [diff] [blame] | 1085 | fi |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 1086 | |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1087 | # Prepend directories to the path on device. |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1088 | PREPEND_TARGET_PATH=$ANDROID_ART_BIN_DIR |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1089 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 1090 | PREPEND_TARGET_PATH="$PREPEND_TARGET_PATH:$ANDROID_ROOT/bin" |
| 1091 | fi |
| 1092 | |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1093 | timeout_dumper_cmd= |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1094 | |
| 1095 | # Check whether signal_dumper is available. |
| 1096 | if [ "$TIMEOUT_DUMPER" = signal_dumper ] ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1097 | # Chroot? Use as prefix for tests. |
| 1098 | TIMEOUT_DUMPER_PATH_PREFIX= |
| 1099 | if [ -n "$CHROOT" ]; then |
| 1100 | TIMEOUT_DUMPER_PATH_PREFIX="$CHROOT/" |
| 1101 | fi |
| 1102 | |
Roland Levillain | 52b4dc9 | 2019-09-12 11:56:52 +0100 | [diff] [blame] | 1103 | # Testing APEX? |
Andreas Gampe | 5aae3db | 2019-09-13 10:24:57 -0700 | [diff] [blame] | 1104 | if adb shell "test -x ${TIMEOUT_DUMPER_PATH_PREFIX}/apex/com.android.art/bin/signal_dumper" ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1105 | TIMEOUT_DUMPER="/apex/com.android.art/bin/signal_dumper" |
| 1106 | # Is it in /system/bin? |
Andreas Gampe | 5aae3db | 2019-09-13 10:24:57 -0700 | [diff] [blame] | 1107 | elif adb shell "test -x ${TIMEOUT_DUMPER_PATH_PREFIX}/system/bin/signal_dumper" ; then |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1108 | TIMEOUT_DUMPER="/system/bin/signal_dumper" |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1109 | else |
Andreas Gampe | 5d775eb | 2019-09-13 09:54:55 -0700 | [diff] [blame] | 1110 | TIMEOUT_DUMPER= |
Andreas Gampe | a613808 | 2019-09-11 11:08:23 -0700 | [diff] [blame] | 1111 | fi |
| 1112 | else |
| 1113 | TIMEOUT_DUMPER= |
| 1114 | fi |
| 1115 | |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1116 | if [ ! -z "$TIMEOUT_DUMPER" ] ; then |
| 1117 | # Use "-l" to dump to logcat. That is convenience for the build bot crash symbolization. |
Andreas Gampe | 38a2818 | 2019-09-13 11:36:11 -0700 | [diff] [blame] | 1118 | # Use exit code 124 for toybox timeout (b/141007616). |
| 1119 | timeout_dumper_cmd="${TIMEOUT_DUMPER} -l -s 15 -e 124" |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1120 | fi |
| 1121 | |
| 1122 | timeout_prefix= |
| 1123 | if [ "$TIME_OUT" = "timeout" ]; then |
| 1124 | # Add timeout command if time out is desired. |
| 1125 | # |
| 1126 | # Note: We first send SIGTERM (the timeout default, signal 15) to the signal dumper, which |
| 1127 | # will induce a full thread dump before killing the process. To ensure any issues in |
| 1128 | # dumping do not lead to a deadlock, we also use the "-k" option to definitely kill the |
| 1129 | # child. |
| 1130 | # Note: Using "--foreground" to not propagate the signal to children, i.e., the runtime. |
David Srbecky | a49b04f | 2019-09-16 14:53:15 +0000 | [diff] [blame] | 1131 | timeout_prefix="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${timeout_dumper_cmd} $cmdline" |
Andreas Gampe | 975d70b | 2019-09-11 11:00:18 -0700 | [diff] [blame] | 1132 | fi |
| 1133 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1134 | # Create a script with the command. The command can get longer than the longest |
| 1135 | # allowed adb command and there is no way to get the exit status from a adb shell |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1136 | # command. Dalvik cache is cleaned before running to make subsequent executions |
| 1137 | # of the script follow the same runtime path. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1138 | cmdline="cd $DEX_LOCATION && \ |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1139 | export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1140 | export ANDROID_DATA=$DEX_LOCATION && \ |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 1141 | export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1142 | export DEX_LOCATION=$DEX_LOCATION && \ |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 1143 | export ANDROID_ROOT=$ANDROID_ROOT && \ |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 1144 | export ANDROID_I18N_ROOT=$ANDROID_I18N_ROOT && \ |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1145 | export ANDROID_ART_ROOT=$ANDROID_ART_ROOT && \ |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 1146 | export ANDROID_TZDATA_ROOT=$ANDROID_TZDATA_ROOT && \ |
Nicolas Geoffray | f39f04c | 2018-03-05 15:42:11 +0000 | [diff] [blame] | 1147 | export ANDROID_LOG_TAGS=$ANDROID_LOG_TAGS && \ |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1148 | rm -rf ${DEX_LOCATION}/dalvik-cache/ && \ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 1149 | mkdir -p ${mkdir_locations} && \ |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 1150 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \ |
Roland Levillain | 72f6774 | 2019-03-06 15:48:08 +0000 | [diff] [blame] | 1151 | export PATH=$PREPEND_TARGET_PATH:\$PATH && \ |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1152 | $profman_cmdline && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1153 | $dex2oat_cmdline && \ |
Nicolas Geoffray | baeaa9b | 2018-01-26 14:31:17 +0000 | [diff] [blame] | 1154 | $dm_cmdline && \ |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 1155 | $vdex_cmdline && \ |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 1156 | $strip_cmdline && \ |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 1157 | $sync_cmdline && \ |
David Srbecky | a49b04f | 2019-09-16 14:53:15 +0000 | [diff] [blame] | 1158 | $timeout_prefix $dalvikvm_cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1159 | |
| 1160 | cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") |
| 1161 | echo "$cmdline" > $cmdfile |
| 1162 | |
| 1163 | if [ "$DEV_MODE" = "y" ]; then |
| 1164 | echo $cmdline |
Alex Light | 219420e | 2019-12-05 10:20:26 -0800 | [diff] [blame] | 1165 | if [ "$USE_GDB" = "y" ] || [ "$USE_GDBSERVER" = "y" ]; then |
| 1166 | echo "Forward ${GDBSERVER_PORT} to local port and connect GDB" |
| 1167 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1168 | fi |
| 1169 | |
| 1170 | if [ "$QUIET" = "n" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1171 | adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1172 | else |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1173 | adb push $cmdfile $CHROOT_DEX_LOCATION/cmdline.sh >/dev/null 2>&1 |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1174 | fi |
| 1175 | |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1176 | exit_status=0 |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1177 | if [ "$DRY_RUN" != "y" ]; then |
Roland Levillain | 76cfe61 | 2017-10-30 13:14:28 +0000 | [diff] [blame] | 1178 | if [ -n "$CHROOT" ]; then |
| 1179 | adb shell chroot "$CHROOT" sh $DEX_LOCATION/cmdline.sh |
| 1180 | else |
| 1181 | adb shell sh $DEX_LOCATION/cmdline.sh |
| 1182 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1183 | exit_status=$? |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1184 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1185 | |
| 1186 | rm -f $cmdfile |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1187 | exit $exit_status |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1188 | else |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1189 | # Host run. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1190 | export ANDROID_PRINTF_LOG=brief |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1191 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1192 | export ANDROID_DATA="$DEX_LOCATION" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 1193 | export ANDROID_ROOT="${ANDROID_ROOT}" |
Victor Chang | 6461124 | 2019-07-05 16:32:41 +0100 | [diff] [blame] | 1194 | export ANDROID_I18N_ROOT="${ANDROID_I18N_ROOT}" |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1195 | export ANDROID_ART_ROOT="${ANDROID_ART_ROOT}" |
Neil Fuller | 26a5dd6 | 2019-03-13 15:16:35 +0000 | [diff] [blame] | 1196 | export ANDROID_TZDATA_ROOT="${ANDROID_TZDATA_ROOT}" |
Alex Light | 6f342dd | 2019-03-27 17:15:42 +0000 | [diff] [blame] | 1197 | if [ "$USE_ZIPAPEX" = "y" ] || [ "$USE_EXRACTED_ZIPAPEX" = "y" ]; then |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1198 | # Put the zipapex files in front of the ld-library-path |
Alex Light | f7f3152 | 2019-02-01 11:14:41 -0800 | [diff] [blame] | 1199 | export LD_LIBRARY_PATH="${ANDROID_DATA}/zipapex/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1200 | export DYLD_LIBRARY_PATH="${ANDROID_DATA}/zipapex/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1201 | else |
| 1202 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 1203 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1204 | fi |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1205 | export PATH="$PATH:$ANDROID_ART_BIN_DIR" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1206 | |
David Srbecky | c9ede38 | 2015-06-20 06:03:53 +0100 | [diff] [blame] | 1207 | # Temporarily disable address space layout randomization (ASLR). |
| 1208 | # This is needed on the host so that the linker loads core.oat at the necessary address. |
| 1209 | export LD_USE_LOAD_BIAS=1 |
| 1210 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1211 | cmdline="$dalvikvm_cmdline" |
| 1212 | |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1213 | if [ "$TIME_OUT" = "gdb" ]; then |
| 1214 | if [ `uname` = "Darwin" ]; then |
| 1215 | # Fall back to timeout on Mac. |
| 1216 | TIME_OUT="timeout" |
Hiroshi Yamauchi | c823eff | 2015-09-01 16:21:35 -0700 | [diff] [blame] | 1217 | elif [ "$ISA" = "x86" ]; then |
| 1218 | # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout. |
| 1219 | TIME_OUT="timeout" |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1220 | else |
| 1221 | # Check if gdb is available. |
| 1222 | gdb --eval-command="quit" > /dev/null 2>&1 |
| 1223 | if [ $? != 0 ]; then |
| 1224 | # gdb isn't available. Fall back to timeout. |
| 1225 | TIME_OUT="timeout" |
| 1226 | fi |
| 1227 | fi |
| 1228 | fi |
| 1229 | |
| 1230 | if [ "$TIME_OUT" = "timeout" ]; then |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1231 | # Add timeout command if time out is desired. |
Andreas Gampe | 038bb22 | 2015-01-13 19:48:14 -0800 | [diff] [blame] | 1232 | # |
Andreas Gampe | 0df2aba | 2019-06-10 16:53:55 -0700 | [diff] [blame] | 1233 | # Note: We first send SIGTERM (the timeout default, signal 15) to the signal dumper, which |
| 1234 | # will induce a full thread dump before killing the process. To ensure any issues in |
| 1235 | # dumping do not lead to a deadlock, we also use the "-k" option to definitely kill the |
| 1236 | # child. |
Andreas Gampe | 4bdcf5d | 2018-12-14 10:48:53 -0800 | [diff] [blame] | 1237 | # Note: Using "--foreground" to not propagate the signal to children, i.e., the runtime. |
Andreas Gampe | 0df2aba | 2019-06-10 16:53:55 -0700 | [diff] [blame] | 1238 | cmdline="timeout --foreground -k 120s ${TIME_OUT_VALUE}s ${TIMEOUT_DUMPER} -s 15 $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1239 | fi |
| 1240 | |
| 1241 | if [ "$DEV_MODE" = "y" ]; then |
Martin Stjernholm | e58624f | 2019-09-20 15:53:40 +0100 | [diff] [blame] | 1242 | for var in ANDROID_PRINTF_LOG ANDROID_DATA ANDROID_ROOT ANDROID_I18N_ROOT ANDROID_TZDATA_ROOT ANDROID_ART_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH LD_USE_LOAD_BIAS; do |
Orion Hodson | ee06c5a | 2018-04-23 13:46:24 +0100 | [diff] [blame] | 1243 | echo EXPORT $var=${!var} |
| 1244 | done |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 1245 | echo "$(declare -f linkdirs)" |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1246 | echo "mkdir -p ${mkdir_locations} && $setupapex_cmdline && $installapex_cmdline && $linkroot_cmdline && $linkroot_overlay_cmdline && $profman_cmdline && $dex2oat_cmdline && $dm_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1247 | fi |
| 1248 | |
| 1249 | cd $ANDROID_BUILD_TOP |
| 1250 | |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1251 | # Make sure we delete any existing compiler artifacts. |
| 1252 | # This enables tests to call the RUN script multiple times in a row |
| 1253 | # without worrying about interference. |
| 1254 | rm -rf ${DEX_LOCATION}/oat |
David Srbecky | 2e4afe8 | 2016-01-27 18:42:06 +0000 | [diff] [blame] | 1255 | rm -rf ${DEX_LOCATION}/dalvik-cache/ |
Calin Juravle | 24bd3f9 | 2017-05-11 00:36:53 -0700 | [diff] [blame] | 1256 | |
Andreas Gampe | b31a8e7 | 2017-05-16 10:30:24 -0700 | [diff] [blame] | 1257 | export ASAN_OPTIONS=$RUN_TEST_ASAN_OPTIONS |
| 1258 | |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 1259 | mkdir -p ${mkdir_locations} || exit 1 |
Alex Light | 20802ca | 2018-12-05 15:36:03 -0800 | [diff] [blame] | 1260 | $setupapex_cmdline || { echo "zipapex extraction failed." >&2 ; exit 2; } |
Alex Light | 7b1f8cc | 2019-01-31 11:04:51 -0800 | [diff] [blame] | 1261 | $installapex_cmdline || { echo "zipapex install failed. cmd was: ${installapex_cmdline}." >&2; find ${mkdir_locations} -type f >&2; exit 2; } |
Alex Light | 680cbf2 | 2018-10-31 11:00:19 -0700 | [diff] [blame] | 1262 | $linkroot_cmdline || { echo "create symlink android-root failed." >&2 ; exit 2; } |
| 1263 | $linkroot_overlay_cmdline || { echo "overlay android-root failed." >&2 ; exit 2; } |
Calin Juravle | 13439f0 | 2017-02-21 01:17:21 -0800 | [diff] [blame] | 1264 | $profman_cmdline || { echo "Profman failed." >&2 ; exit 2; } |
Nicolas Geoffray | f0eaada | 2020-02-09 22:21:26 +0000 | [diff] [blame] | 1265 | $dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
| 1266 | $dm_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
| 1267 | $vdex_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 1268 | $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; } |
Igor Murashkin | 271a0f8 | 2017-02-14 21:14:17 +0000 | [diff] [blame] | 1269 | $sync_cmdline || { echo "Sync failed." >&2 ; exit 4; } |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1270 | |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 1271 | if [ "$CREATE_RUNNER" = "y" ]; then |
| 1272 | echo "#!/bin/bash" > ${DEX_LOCATION}/runit.sh |
| 1273 | for var in ANDROID_PRINTF_LOG ANDROID_DATA ANDROID_ROOT ANDROID_I18N_ROOT ANDROID_TZDATA_ROOT ANDROID_ART_ROOT LD_LIBRARY_PATH DYLD_LIBRARY_PATH PATH LD_USE_LOAD_BIAS; do |
| 1274 | echo export $var="${!var}" >> ${DEX_LOCATION}/runit.sh |
| 1275 | done |
Alex Light | 4f915d2 | 2020-01-09 17:51:25 -0800 | [diff] [blame] | 1276 | if [ "$DEV_MODE" = "y" ]; then |
| 1277 | echo $cmdline "2>&1" >> ${DEX_LOCATION}/runit.sh |
| 1278 | else |
| 1279 | echo 'STDERR=$(mktemp)' >> ${DEX_LOCATION}/runit.sh |
| 1280 | echo 'STDOUT=$(mktemp)' >> ${DEX_LOCATION}/runit.sh |
| 1281 | echo $cmdline '2>${STDERR} >${STDOUT}' >> ${DEX_LOCATION}/runit.sh |
| 1282 | echo 'if diff ${STDOUT} $ANDROID_DATA/expected.txt; then' >> ${DEX_LOCATION}/runit.sh |
| 1283 | echo ' rm -f ${STDOUT} ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1284 | echo ' exit 0' >> ${DEX_LOCATION}/runit.sh |
| 1285 | echo 'else' >> ${DEX_LOCATION}/runit.sh |
| 1286 | echo ' echo STDOUT:' >> ${DEX_LOCATION}/runit.sh |
| 1287 | echo ' cat ${STDOUT}' >> ${DEX_LOCATION}/runit.sh |
| 1288 | echo ' echo STDERR:' >> ${DEX_LOCATION}/runit.sh |
| 1289 | echo ' cat ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1290 | echo ' rm -f ${STDOUT} ${STDERR}' >> ${DEX_LOCATION}/runit.sh |
| 1291 | echo ' exit 1' >> ${DEX_LOCATION}/runit.sh |
| 1292 | echo 'fi' >> ${DEX_LOCATION}/runit.sh |
| 1293 | fi |
Alex Light | 8d94ddd | 2019-12-18 11:13:03 -0800 | [diff] [blame] | 1294 | chmod u+x $DEX_LOCATION/runit.sh |
| 1295 | echo "Runnable test script written to ${DEX_LOCATION}/runit.sh" |
| 1296 | fi |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 1297 | if [ "$DRY_RUN" = "y" ]; then |
| 1298 | exit 0 |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 1299 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1300 | |
| 1301 | if [ "$USE_GDB" = "y" ]; then |
| 1302 | # When running under gdb, we cannot do piping and grepping... |
Alex Light | e4b4a18 | 2019-02-12 14:19:49 -0800 | [diff] [blame] | 1303 | $cmdline "$@" |
| 1304 | elif [ "$USE_GDBSERVER" = "y" ]; then |
| 1305 | echo "Connect to $GDBSERVER_PORT" |
| 1306 | # When running under gdb, we cannot do piping and grepping... |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 1307 | $cmdline "$@" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1308 | else |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1309 | if [ "$TIME_OUT" != "gdb" ]; then |
| 1310 | trap 'kill -INT -$pid' INT |
| 1311 | $cmdline "$@" 2>&1 & pid=$! |
| 1312 | wait $pid |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1313 | exit_value=$? |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1314 | # Add extra detail if time out is enabled. |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1315 | if [ $exit_value = 124 ] && [ "$TIME_OUT" = "timeout" ]; then |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1316 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 1317 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1318 | exit $exit_value |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1319 | else |
| 1320 | # With a thread dump that uses gdb if a timeout. |
| 1321 | trap 'kill -INT -$pid' INT |
| 1322 | $cmdline "$@" 2>&1 & pid=$! |
| 1323 | # Spawn a watcher process. |
| 1324 | ( sleep $TIME_OUT_VALUE && \ |
| 1325 | echo "##### Thread dump using gdb on test timeout" && \ |
| 1326 | ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \ |
| 1327 | --eval-command="call exit(124)" --eval-command=quit || \ |
| 1328 | kill $pid )) 2> /dev/null & watcher=$! |
| 1329 | wait $pid |
| 1330 | test_exit_status=$? |
| 1331 | pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well |
| 1332 | if [ $test_exit_status = 0 ]; then |
| 1333 | # The test finished normally. |
| 1334 | exit 0 |
| 1335 | else |
| 1336 | # The test failed or timed out. |
| 1337 | if [ $test_exit_status = 124 ]; then |
| 1338 | # The test timed out. |
| 1339 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 1340 | fi |
Alex Light | 722d671 | 2018-02-12 17:41:12 +0000 | [diff] [blame] | 1341 | exit $test_exit_status |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 1342 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 1343 | fi |
| 1344 | fi |
| 1345 | fi |