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