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