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