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