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