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 | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 22 | FALSE_BIN="/system/bin/false" |
| 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" |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 65 | VDEX_FILTER="" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 66 | |
| 67 | while true; do |
| 68 | if [ "x$1" = "x--quiet" ]; then |
| 69 | QUIET="y" |
| 70 | shift |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 71 | elif [ "x$1" = "x--jvmti" ]; then |
| 72 | IS_JVMTI_TEST="y" |
| 73 | shift |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 74 | elif [ "x$1" = "x-O" ]; then |
Alex Light | e06b634 | 2017-01-05 14:37:21 -0800 | [diff] [blame] | 75 | TEST_IS_NDEBUG="y" |
Alex Light | faf90b6 | 2016-08-12 14:43:48 -0700 | [diff] [blame] | 76 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 77 | elif [ "x$1" = "x--lib" ]; then |
| 78 | shift |
| 79 | if [ "x$1" = "x" ]; then |
| 80 | echo "$0 missing argument to --lib" 1>&2 |
| 81 | exit 1 |
| 82 | fi |
| 83 | LIB="$1" |
| 84 | shift |
Alex Light | 97acf19 | 2016-03-17 09:59:38 -0700 | [diff] [blame] | 85 | elif [ "x$1" = "x--gc-stress" ]; then |
| 86 | # Give an extra 5 mins if we are gc-stress. |
| 87 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300)) |
| 88 | shift |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 89 | elif [ "x$1" = "x--testlib" ]; then |
| 90 | shift |
| 91 | if [ "x$1" = "x" ]; then |
| 92 | echo "$0 missing argument to --testlib" 1>&2 |
| 93 | exit 1 |
| 94 | fi |
Mathieu Chartier | de286fd | 2015-09-03 18:10:29 -0700 | [diff] [blame] | 95 | ARGS="${ARGS} $1" |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 96 | shift |
David Srbecky | 5288611 | 2016-01-22 13:56:47 +0000 | [diff] [blame] | 97 | elif [ "x$1" = "x--args" ]; then |
| 98 | shift |
| 99 | if [ "x$1" = "x" ]; then |
| 100 | echo "$0 missing argument to --args" 1>&2 |
| 101 | exit 1 |
| 102 | fi |
| 103 | ARGS="${ARGS} $1" |
| 104 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 105 | elif [ "x$1" = "x-Xcompiler-option" ]; then |
| 106 | shift |
| 107 | option="$1" |
| 108 | FLAGS="${FLAGS} -Xcompiler-option $option" |
| 109 | COMPILE_FLAGS="${COMPILE_FLAGS} $option" |
| 110 | shift |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 111 | elif [ "x$1" = "x--android-runtime-option" ]; then |
| 112 | shift |
| 113 | option="$1" |
| 114 | ANDROID_FLAGS="${ANDROID_FLAGS} $option" |
| 115 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 116 | elif [ "x$1" = "x--runtime-option" ]; then |
| 117 | shift |
| 118 | option="$1" |
| 119 | FLAGS="${FLAGS} $option" |
| 120 | shift |
| 121 | elif [ "x$1" = "x--boot" ]; then |
| 122 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 123 | BOOT_IMAGE="$1" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 124 | shift |
| 125 | elif [ "x$1" = "x--no-dex2oat" ]; then |
| 126 | DEX2OAT="-Xcompiler:${FALSE_BIN}" |
Andreas Gampe | 6535703 | 2015-02-19 15:10:24 -0800 | [diff] [blame] | 127 | USE_DEX2OAT_AND_PATCHOAT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 128 | shift |
| 129 | elif [ "x$1" = "x--no-patchoat" ]; then |
| 130 | PATCHOAT="-Xpatchoat:${FALSE_BIN}" |
Andreas Gampe | 6535703 | 2015-02-19 15:10:24 -0800 | [diff] [blame] | 131 | USE_DEX2OAT_AND_PATCHOAT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 132 | shift |
| 133 | elif [ "x$1" = "x--relocate" ]; then |
| 134 | RELOCATE="y" |
| 135 | shift |
| 136 | elif [ "x$1" = "x--no-relocate" ]; then |
| 137 | RELOCATE="n" |
| 138 | shift |
| 139 | elif [ "x$1" = "x--prebuild" ]; then |
| 140 | PREBUILD="y" |
| 141 | shift |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 142 | elif [ "x$1" = "x--no-app-image" ]; then |
| 143 | APP_IMAGE="n" |
| 144 | shift |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 145 | elif [ "x$1" = "x--strip-dex" ]; then |
| 146 | STRIP_DEX="y" |
| 147 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 148 | elif [ "x$1" = "x--host" ]; then |
| 149 | HOST="y" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 150 | ANDROID_ROOT="$ANDROID_HOST_OUT" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 151 | shift |
| 152 | elif [ "x$1" = "x--no-prebuild" ]; then |
| 153 | PREBUILD="n" |
| 154 | shift |
| 155 | elif [ "x$1" = "x--no-image" ]; then |
| 156 | HAVE_IMAGE="n" |
| 157 | shift |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 158 | elif [ "x$1" = "x--secondary" ]; then |
| 159 | SECONDARY_DEX=":$DEX_LOCATION/$TEST_NAME-ex.jar" |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 160 | # Enable cfg-append to make sure we get the dump for both dex files. |
| 161 | # (otherwise the runtime compilation of the secondary dex will overwrite |
Roland Levillain | b0103ca | 2016-11-01 14:48:47 +0000 | [diff] [blame] | 162 | # the dump of the first one). |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 163 | FLAGS="${FLAGS} -Xcompiler-option --dump-cfg-append" |
| 164 | COMPILE_FLAGS="${COMPILE_FLAGS} --dump-cfg-append" |
Jeff Hao | 207a37d | 2014-10-29 17:24:25 -0700 | [diff] [blame] | 165 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 166 | elif [ "x$1" = "x--debug" ]; then |
| 167 | DEBUGGER="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 168 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 169 | shift |
| 170 | elif [ "x$1" = "x--gdb" ]; then |
| 171 | USE_GDB="y" |
| 172 | DEV_MODE="y" |
Brian Carlstrom | 93d6ce5 | 2014-11-04 22:31:35 -0800 | [diff] [blame] | 173 | TIME_OUT="n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 174 | shift |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 175 | elif [ "x$1" = "x--gdb-arg" ]; then |
| 176 | shift |
| 177 | gdb_arg="$1" |
| 178 | GDB_ARGS="${GDB_ARGS} $gdb_arg" |
| 179 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 180 | elif [ "x$1" = "x--zygote" ]; then |
| 181 | ZYGOTE="-Xzygote" |
| 182 | msg "Spawning from zygote" |
| 183 | shift |
| 184 | elif [ "x$1" = "x--dev" ]; then |
| 185 | DEV_MODE="y" |
| 186 | shift |
| 187 | elif [ "x$1" = "x--interpreter" ]; then |
| 188 | INTERPRETER="y" |
| 189 | shift |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 190 | elif [ "x$1" = "x--jit" ]; then |
| 191 | JIT="y" |
| 192 | shift |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 193 | elif [ "x$1" = "x--jvm" ]; then |
| 194 | USE_JVM="y" |
| 195 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 196 | elif [ "x$1" = "x--invoke-with" ]; then |
| 197 | shift |
| 198 | if [ "x$1" = "x" ]; then |
| 199 | echo "$0 missing argument to --invoke-with" 1>&2 |
| 200 | exit 1 |
| 201 | fi |
| 202 | if [ "x$INVOKE_WITH" = "x" ]; then |
| 203 | INVOKE_WITH="$1" |
| 204 | else |
| 205 | INVOKE_WITH="$INVOKE_WITH $1" |
| 206 | fi |
| 207 | shift |
| 208 | elif [ "x$1" = "x--no-verify" ]; then |
| 209 | VERIFY="n" |
| 210 | shift |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 211 | elif [ "x$1" = "x--verify-soft-fail" ]; then |
| 212 | VERIFY="s" |
| 213 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 214 | elif [ "x$1" = "x--no-optimize" ]; then |
| 215 | OPTIMIZE="n" |
| 216 | shift |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 217 | elif [ "x$1" = "x--android-root" ]; then |
| 218 | shift |
| 219 | ANDROID_ROOT="$1" |
| 220 | shift |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 221 | elif [ "x$1" = "x--instruction-set-features" ]; then |
| 222 | shift |
| 223 | INSTRUCTION_SET_FEATURES="$1" |
| 224 | shift |
Mathieu Chartier | 2576be2 | 2016-05-24 10:24:53 -0700 | [diff] [blame] | 225 | elif [ "x$1" = "x--timeout" ]; then |
| 226 | shift |
| 227 | TIME_OUT_VALUE="$1" |
| 228 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 229 | elif [ "x$1" = "x--" ]; then |
| 230 | shift |
| 231 | break |
| 232 | elif [ "x$1" = "x--64" ]; then |
| 233 | ISA="x86_64" |
| 234 | GDB_SERVER="gdbserver64" |
| 235 | DALVIKVM="dalvikvm64" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 236 | LIBRARY_DIRECTORY="lib64" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 237 | TEST_DIRECTORY="nativetest64" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 238 | ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" |
| 239 | shift |
Andreas Gampe | c23c9c9 | 2014-10-28 14:47:25 -0700 | [diff] [blame] | 240 | elif [ "x$1" = "x--pic-test" ]; then |
| 241 | FLAGS="${FLAGS} -Xcompiler-option --compile-pic" |
| 242 | COMPILE_FLAGS="${COMPILE_FLAGS} --compile-pic" |
| 243 | shift |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 244 | elif [ "x$1" = "x--experimental" ]; then |
| 245 | if [ "$#" -lt 2 ]; then |
| 246 | echo "missing --experimental option" 1>&2 |
| 247 | exit 1 |
| 248 | fi |
| 249 | EXPERIMENTAL="$EXPERIMENTAL $2" |
| 250 | shift 2 |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 251 | elif [ "x$1" = "x--external-log-tags" ]; then |
| 252 | EXTERNAL_LOG_TAGS="y" |
| 253 | shift |
| 254 | elif [ "x$1" = "x--dry-run" ]; then |
| 255 | DRY_RUN="y" |
| 256 | shift |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 257 | elif [ "x$1" = "x--vdex" ]; then |
| 258 | TEST_VDEX="y" |
| 259 | shift |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 260 | elif [ "x$1" = "x--vdex-filter" ]; then |
| 261 | shift |
| 262 | option="$1" |
| 263 | VDEX_FILTER="--compiler-filter=$option" |
| 264 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 265 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
| 266 | echo "unknown $0 option: $1" 1>&2 |
| 267 | exit 1 |
| 268 | else |
| 269 | break |
| 270 | fi |
| 271 | done |
| 272 | |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 273 | if [ "$USE_JVM" = "n" ]; then |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 274 | FLAGS="${FLAGS} ${ANDROID_FLAGS}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 275 | for feature in ${EXPERIMENTAL}; do |
Alex Light | fa02285 | 2015-10-28 09:13:20 -0700 | [diff] [blame] | 276 | FLAGS="${FLAGS} -Xexperimental:${feature} -Xcompiler-option --runtime-arg -Xcompiler-option -Xexperimental:${feature}" |
Alex Light | 8a0e033 | 2015-10-26 10:11:58 -0700 | [diff] [blame] | 277 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xexperimental:${feature}" |
| 278 | done |
| 279 | fi |
| 280 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 281 | if [ "x$1" = "x" ] ; then |
| 282 | MAIN="Main" |
| 283 | else |
| 284 | MAIN="$1" |
Andreas Gampe | f2fdc73 | 2014-06-11 08:20:47 -0700 | [diff] [blame] | 285 | shift |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 286 | fi |
| 287 | |
| 288 | if [ "$ZYGOTE" = "" ]; then |
| 289 | if [ "$OPTIMIZE" = "y" ]; then |
| 290 | if [ "$VERIFY" = "y" ]; then |
| 291 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 292 | else |
| 293 | DEX_OPTIMIZE="-Xdexopt:all" |
| 294 | fi |
| 295 | msg "Performing optimizations" |
| 296 | else |
| 297 | DEX_OPTIMIZE="-Xdexopt:none" |
| 298 | msg "Skipping optimizations" |
| 299 | fi |
| 300 | |
| 301 | if [ "$VERIFY" = "y" ]; then |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 302 | JVM_VERIFY_ARG="-Xverify:all" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 303 | msg "Performing verification" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 304 | elif [ "$VERIFY" = "s" ]; then |
| 305 | JVM_VERIFY_ARG="Xverify:all" |
| 306 | DEX_VERIFY="-Xverify:softfail" |
| 307 | msg "Forcing verification to be soft fail" |
| 308 | else # VERIFY = "n" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 309 | DEX_VERIFY="-Xverify:none" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 310 | JVM_VERIFY_ARG="-Xverify:none" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 311 | msg "Skipping verification" |
| 312 | fi |
| 313 | fi |
| 314 | |
| 315 | msg "------------------------------" |
| 316 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 317 | if [ "$DEBUGGER" = "y" ]; then |
| 318 | # Use this instead for ddms and connect by running 'ddms': |
| 319 | # DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" |
| 320 | # TODO: add a separate --ddms option? |
| 321 | |
| 322 | PORT=12345 |
| 323 | msg "Waiting for jdb to connect:" |
| 324 | if [ "$HOST" = "n" ]; then |
| 325 | msg " adb forward tcp:$PORT tcp:$PORT" |
| 326 | fi |
| 327 | msg " jdb -attach localhost:$PORT" |
| 328 | DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
| 329 | fi |
| 330 | |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 331 | if [ "$IS_JVMTI_TEST" = "y" ]; then |
| 332 | plugin=libopenjdkjvmtid.so |
| 333 | agent=libtiagentd.so |
| 334 | lib=tiagentd |
| 335 | if [[ "$TEST_IS_NDEBUG" = "y" ]]; then |
| 336 | agent=libtiagent.so |
| 337 | plugin=libopenjdkjvmti.so |
| 338 | lib=tiagent |
| 339 | fi |
| 340 | |
| 341 | ARGS="${ARGS} ${lib}" |
| 342 | if [[ "$USE_JVM" = "y" ]]; then |
| 343 | FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=${TEST_NAME},jvm" |
| 344 | else |
| 345 | FLAGS="${FLAGS} -agentpath:${agent}=${TEST_NAME},art" |
| 346 | FLAGS="${FLAGS} -Xplugin:${plugin}" |
Nicolas Geoffray | a0619e2 | 2016-12-20 13:57:43 +0000 | [diff] [blame] | 347 | FLAGS="${FLAGS} -Xcompiler-option --debuggable" |
Alex Light | fba89fe | 2017-01-12 16:11:02 -0800 | [diff] [blame] | 348 | # Always make the compilation be debuggable. |
| 349 | COMPILE_FLAGS="${COMPILE_FLAGS} --debuggable" |
| 350 | fi |
| 351 | fi |
| 352 | |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 353 | if [ "$USE_JVM" = "y" ]; then |
Alex Light | 9c20a14 | 2016-08-23 15:05:12 -0700 | [diff] [blame] | 354 | export LD_LIBRARY_PATH=${ANDROID_HOST_OUT}/lib64 |
Mathieu Chartier | a61894d | 2015-04-23 16:32:54 -0700 | [diff] [blame] | 355 | # 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] | 356 | # We pass the classes2 path whether it's used (src-multidex) or not. |
| 357 | 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] | 358 | if [ "$DEV_MODE" = "y" ]; then |
| 359 | echo $cmdline |
| 360 | fi |
| 361 | $cmdline |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 362 | exit |
| 363 | fi |
| 364 | |
| 365 | |
| 366 | if [ "$HAVE_IMAGE" = "n" ]; then |
Nicolas Geoffray | 47e61d5 | 2017-01-31 09:13:52 +0000 | [diff] [blame] | 367 | # Add 5 minutes to give some time to generate the boot image. |
| 368 | TIME_OUT_VALUE=$((${TIME_OUT_VALUE} + 300)) |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 369 | DALVIKVM_BOOT_OPT="-Ximage:/system/non-existant/core.art" |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 370 | else |
| 371 | DALVIKVM_BOOT_OPT="-Ximage:${BOOT_IMAGE}" |
Nicolas Geoffray | 288a4a2 | 2014-10-07 11:02:40 +0100 | [diff] [blame] | 372 | fi |
| 373 | |
| 374 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 375 | if [ "$USE_GDB" = "y" ]; then |
| 376 | if [ "$HOST" = "n" ]; then |
| 377 | GDB="$GDB_SERVER :5039" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 378 | else |
| 379 | if [ `uname` = "Darwin" ]; then |
| 380 | GDB=lldb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 381 | GDB_ARGS="$GDB_ARGS -- $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 382 | DALVIKVM= |
| 383 | else |
| 384 | GDB=gdb |
Mathieu Chartier | c0a8a80 | 2014-10-17 15:58:01 -0700 | [diff] [blame] | 385 | GDB_ARGS="$GDB_ARGS --args $DALVIKVM" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 386 | # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. |
| 387 | # gdbargs="--annotate=3 $gdbargs" |
| 388 | fi |
| 389 | fi |
| 390 | fi |
| 391 | |
| 392 | if [ "$INTERPRETER" = "y" ]; then |
Nicolas Geoffray | e722d29 | 2015-12-15 11:51:37 +0000 | [diff] [blame] | 393 | INT_OPTS="-Xint" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 394 | if [ "$VERIFY" = "y" ] ; then |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 395 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=interpret-only" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 396 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 397 | elif [ "$VERIFY" = "s" ]; then |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 398 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-at-runtime" |
Igor Murashkin | 7617abd | 2015-07-10 18:27:47 -0700 | [diff] [blame] | 399 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-at-runtime" |
| 400 | DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail" |
| 401 | else # VERIFY = "n" |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 402 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none" |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 403 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none" |
| 404 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 405 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 406 | fi |
| 407 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 408 | if [ "$JIT" = "y" ]; then |
Nicolas Geoffray | e722d29 | 2015-12-15 11:51:37 +0000 | [diff] [blame] | 409 | INT_OPTS="-Xusejit:true" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 410 | if [ "$VERIFY" = "y" ] ; then |
Calin Juravle | 0966558 | 2016-12-20 14:00:48 +0000 | [diff] [blame] | 411 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=interpret-only" |
| 412 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 413 | else |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 414 | INT_OPTS="${INT_OPTS} -Xcompiler-option --compiler-filter=verify-none" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 415 | COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none" |
| 416 | DEX_VERIFY="${DEX_VERIFY} -Xverify:none" |
| 417 | fi |
| 418 | fi |
| 419 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 420 | JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" |
| 421 | |
| 422 | if [ "$RELOCATE" = "y" ]; then |
| 423 | COMPILE_FLAGS="${COMPILE_FLAGS} --include-patch-information --runtime-arg -Xnorelocate" |
| 424 | FLAGS="${FLAGS} -Xrelocate -Xcompiler-option --include-patch-information" |
| 425 | if [ "$HOST" = "y" ]; then |
| 426 | # Run test sets a fairly draconian ulimit that we will likely blow right over |
| 427 | # since we are relocating. Get the total size of the /system/framework directory |
| 428 | # in 512 byte blocks and set it as the ulimit. This should be more than enough |
| 429 | # room. |
| 430 | if [ ! `uname` = "Darwin" ]; then # TODO: Darwin doesn't support "du -B..." |
Alex Light | d26b7e4 | 2016-04-08 09:44:54 -0700 | [diff] [blame] | 431 | ulimit -S $(du -c -B512 ${ANDROID_HOST_OUT}/framework 2>/dev/null | tail -1 | cut -f1) || exit 1 |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 432 | fi |
| 433 | fi |
| 434 | else |
| 435 | FLAGS="$FLAGS -Xnorelocate" |
| 436 | COMPILE_FLAGS="${COMPILE_FLAGS} --runtime-arg -Xnorelocate" |
Mathieu Chartier | cae2ed9 | 2015-06-09 13:02:50 -0700 | [diff] [blame] | 437 | if [ "$HOST" = "y" ]; then |
| 438 | # Increase ulimit to 64MB in case we are running hprof test. |
| 439 | ulimit -S 64000 || exit 1 |
| 440 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 441 | fi |
| 442 | |
| 443 | if [ "$HOST" = "n" ]; then |
Nicolas Geoffray | d295bc8 | 2016-11-04 13:03:05 +0000 | [diff] [blame] | 444 | # Need to be root to query /data/dalvik-cache |
| 445 | adb root > /dev/null |
| 446 | adb wait-for-device |
| 447 | ISA= |
| 448 | ISA_adb_invocation= |
| 449 | ISA_outcome= |
| 450 | # We iterate a few times to workaround an adb issue. b/32655576 |
| 451 | for i in {1..10}; do |
| 452 | ISA_adb_invocation=$(adb shell ls -F /data/dalvik-cache) |
| 453 | ISA_outcome=$? |
| 454 | ISA=$(echo $ISA_adb_invocation | grep -Ewo "${ARCHITECTURES_PATTERN}") |
| 455 | if [ x"$ISA" != "x" ]; then |
| 456 | break; |
| 457 | fi |
| 458 | done |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 459 | if [ x"$ISA" = "x" ]; then |
| 460 | echo "Unable to determine architecture" |
Nicolas Geoffray | 8f500fa | 2016-11-03 11:18:48 +0000 | [diff] [blame] | 461 | # Print a few things for helping diagnosing the problem. |
Nicolas Geoffray | d295bc8 | 2016-11-04 13:03:05 +0000 | [diff] [blame] | 462 | echo "adb invocation output: $ISA_adb_invocation" |
| 463 | echo "adb invocation outcome: $ISA_outcome" |
Nicolas Geoffray | 8f500fa | 2016-11-03 11:18:48 +0000 | [diff] [blame] | 464 | echo $(adb shell ls -F /data/dalvik-cache) |
| 465 | echo $(adb shell ls /data/dalvik-cache) |
| 466 | echo ${ARCHITECTURES_PATTERN} |
| 467 | echo $(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}") |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 468 | exit 1 |
| 469 | fi |
| 470 | fi |
| 471 | |
Wojciech Staszkiewicz | e663653 | 2016-09-23 10:59:55 -0700 | [diff] [blame] | 472 | # Prevent test from silently falling back to interpreter in no-prebuild mode. This happens |
| 473 | # when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking |
| 474 | # full path to dex, stripping leading '/', appending '@classes.vdex' and changing every |
| 475 | # remaining '/' into '@'. |
| 476 | if [ "$HOST" = "y" ]; then |
| 477 | max_filename_size=$(getconf NAME_MAX $DEX_LOCATION) |
| 478 | else |
| 479 | # There is no getconf on device, fallback to standard value. See NAME_MAX in kernel <linux/limits.h> |
| 480 | max_filename_size=255 |
| 481 | fi |
| 482 | # Compute VDEX_NAME. |
| 483 | DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}" |
| 484 | VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex" |
| 485 | if [ ${#VDEX_NAME} -gt $max_filename_size ]; then |
| 486 | echo "Dex location path too long." |
| 487 | exit 1 |
| 488 | fi |
| 489 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 490 | dex2oat_cmdline="true" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 491 | vdex_cmdline="true" |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 492 | mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA" |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 493 | strip_cmdline="true" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 494 | |
Jeff Hao | dcdc85b | 2015-12-04 14:06:18 -0800 | [diff] [blame] | 495 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 496 | if [ "$PREBUILD" = "y" ]; then |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 497 | mkdir_locations="${mkdir_locations} ${DEX_LOCATION}/oat/$ISA" |
Calin Juravle | 857f058 | 2016-12-20 14:36:59 +0000 | [diff] [blame] | 498 | if [ "$APP_IMAGE" = "y" ]; then |
| 499 | # Pick a base that will force the app image to get relocated. |
| 500 | app_image="--base=0x4000 --app-image-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.art" |
| 501 | fi |
| 502 | |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 503 | dex2oat_cmdline="$INVOKE_WITH $ANDROID_ROOT/bin/dex2oatd \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 504 | $COMPILE_FLAGS \ |
Nicolas Geoffray | 68e25eb | 2014-10-29 23:02:11 +0000 | [diff] [blame] | 505 | --boot-image=${BOOT_IMAGE} \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 506 | --dex-file=$DEX_LOCATION/$TEST_NAME.jar \ |
Andreas Gampe | 1475924 | 2016-03-23 10:54:21 -0700 | [diff] [blame] | 507 | --oat-file=$DEX_LOCATION/oat/$ISA/$TEST_NAME.odex \ |
Jeff Hao | dcdc85b | 2015-12-04 14:06:18 -0800 | [diff] [blame] | 508 | ${app_image} \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 509 | --instruction-set=$ISA" |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 510 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 511 | dex2oat_cmdline="${dex2oat_cmdline} --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
| 512 | fi |
Andreas Gampe | 2ea7b70 | 2015-08-07 08:07:16 -0700 | [diff] [blame] | 513 | |
| 514 | # Add in a timeout. This is important for testing the compilation/verification time of |
| 515 | # pathological cases. |
| 516 | # Note: as we don't know how decent targets are (e.g., emulator), only do this on the host for |
| 517 | # now. We should try to improve this. |
| 518 | # The current value is rather arbitrary. run-tests should compile quickly. |
| 519 | if [ "$HOST" != "n" ]; then |
| 520 | # Use SIGRTMIN+2 to try to dump threads. |
| 521 | # Use -k 1m to SIGKILL it a minute later if it hasn't ended. |
| 522 | dex2oat_cmdline="timeout -k 1m -s SIGRTMIN+2 1m ${dex2oat_cmdline}" |
| 523 | fi |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 524 | if [ "$TEST_VDEX" = "y" ]; then |
Nicolas Geoffray | 7498105 | 2017-01-16 17:54:09 +0000 | [diff] [blame] | 525 | vdex_cmdline="${dex2oat_cmdline} ${VDEX_FILTER} --input-vdex=$DEX_LOCATION/oat/$ISA/$TEST_NAME.vdex" |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 526 | fi |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 527 | fi |
| 528 | |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 529 | if [ "$STRIP_DEX" = "y" ]; then |
| 530 | strip_cmdline="zip --quiet --delete $DEX_LOCATION/$TEST_NAME.jar classes.dex" |
| 531 | fi |
| 532 | |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 533 | DALVIKVM_ISA_FEATURES_ARGS="" |
| 534 | if [ "x$INSTRUCTION_SET_FEATURES" != "x" ] ; then |
| 535 | DALVIKVM_ISA_FEATURES_ARGS="-Xcompiler-option --instruction-set-features=${INSTRUCTION_SET_FEATURES}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 536 | fi |
| 537 | |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 538 | # java.io.tmpdir can only be set at launch time. |
| 539 | TMP_DIR_OPTION="" |
| 540 | if [ "$HOST" = "n" ]; then |
| 541 | TMP_DIR_OPTION="-Djava.io.tmpdir=/data/local/tmp" |
| 542 | fi |
| 543 | |
Nicolas Geoffray | a73280d | 2016-02-15 13:05:16 +0000 | [diff] [blame] | 544 | # We set DumpNativeStackOnSigQuit to false to avoid stressing libunwind. |
| 545 | # b/27185632 |
| 546 | # b/24664297 |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 547 | dalvikvm_cmdline="$INVOKE_WITH $GDB $ANDROID_ROOT/bin/$DALVIKVM \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 548 | $GDB_ARGS \ |
| 549 | $FLAGS \ |
Andreas Gampe | 2b0fa5b | 2014-10-31 18:12:30 -0700 | [diff] [blame] | 550 | $DEX_VERIFY \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 551 | -XXlib:$LIB \ |
| 552 | $PATCHOAT \ |
| 553 | $DEX2OAT \ |
Andreas Gampe | 4d2ef33 | 2015-08-05 09:24:45 -0700 | [diff] [blame] | 554 | $DALVIKVM_ISA_FEATURES_ARGS \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 555 | $ZYGOTE \ |
| 556 | $JNI_OPTS \ |
| 557 | $INT_OPTS \ |
| 558 | $DEBUGGER_OPTS \ |
| 559 | $DALVIKVM_BOOT_OPT \ |
Nicolas Geoffray | c525604 | 2015-12-26 19:41:37 +0000 | [diff] [blame] | 560 | $TMP_DIR_OPTION \ |
Nicolas Geoffray | a73280d | 2016-02-15 13:05:16 +0000 | [diff] [blame] | 561 | -XX:DumpNativeStackOnSigQuit:false \ |
Mathieu Chartier | 031768a | 2015-08-27 10:25:02 -0700 | [diff] [blame] | 562 | -cp $DEX_LOCATION/$TEST_NAME.jar$SECONDARY_DEX $MAIN $ARGS" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 563 | |
Andreas Gampe | 3ad5d5e | 2015-02-03 18:26:55 -0800 | [diff] [blame] | 564 | # Remove whitespace. |
| 565 | dex2oat_cmdline=$(echo $dex2oat_cmdline) |
| 566 | dalvikvm_cmdline=$(echo $dalvikvm_cmdline) |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 567 | vdex_cmdline=$(echo $vdex_cmdline) |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 568 | |
| 569 | if [ "$HOST" = "n" ]; then |
| 570 | adb root > /dev/null |
| 571 | adb wait-for-device |
| 572 | if [ "$QUIET" = "n" ]; then |
| 573 | adb shell rm -r $DEX_LOCATION |
| 574 | adb shell mkdir -p $DEX_LOCATION |
| 575 | adb push $TEST_NAME.jar $DEX_LOCATION |
| 576 | adb push $TEST_NAME-ex.jar $DEX_LOCATION |
| 577 | else |
| 578 | adb shell rm -r $DEX_LOCATION >/dev/null 2>&1 |
| 579 | adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1 |
| 580 | adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1 |
| 581 | adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1 |
| 582 | fi |
| 583 | |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 584 | LD_LIBRARY_PATH=/data/$TEST_DIRECTORY/art/$ISA |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 585 | if [ "$ANDROID_ROOT" != "/system" ]; then |
| 586 | # Current default installation is dalvikvm 64bits and dex2oat 32bits, |
| 587 | # so we can only use LD_LIBRARY_PATH when testing on a local |
| 588 | # installation. |
Alex Light | 7233c7e | 2016-07-28 10:07:45 -0700 | [diff] [blame] | 589 | LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBRARY_DIRECTORY:$LD_LIBRARY_PATH |
Nicolas Geoffray | eb441dd | 2014-10-31 15:34:50 +0000 | [diff] [blame] | 590 | fi |
| 591 | |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 592 | PUBLIC_LIBS=libart.so:libartd.so |
| 593 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 594 | # Create a script with the command. The command can get longer than the longest |
| 595 | # 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] | 596 | # command. Dalvik cache is cleaned before running to make subsequent executions |
| 597 | # of the script follow the same runtime path. |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 598 | cmdline="cd $DEX_LOCATION && \ |
| 599 | export ANDROID_DATA=$DEX_LOCATION && \ |
Dimitry Ivanov | 90d48f2 | 2016-05-05 17:24:28 -0700 | [diff] [blame] | 600 | export ANDROID_ADDITIONAL_PUBLIC_LIBRARIES=$PUBLIC_LIBS && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 601 | export DEX_LOCATION=$DEX_LOCATION && \ |
Nicolas Geoffray | c8f23fc | 2014-10-28 17:59:47 +0000 | [diff] [blame] | 602 | export ANDROID_ROOT=$ANDROID_ROOT && \ |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 603 | rm -rf ${DEX_LOCATION}/dalvik-cache/ && \ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 604 | mkdir -p ${mkdir_locations} && \ |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 605 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH && \ |
Nicolas Geoffray | 4f7fdd2 | 2015-04-24 11:57:37 +0100 | [diff] [blame] | 606 | export PATH=$ANDROID_ROOT/bin:$PATH && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 607 | $dex2oat_cmdline && \ |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 608 | $vdex_cmdline && \ |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 609 | $strip_cmdline && \ |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 610 | $dalvikvm_cmdline" |
| 611 | |
| 612 | cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") |
| 613 | echo "$cmdline" > $cmdfile |
| 614 | |
| 615 | if [ "$DEV_MODE" = "y" ]; then |
| 616 | echo $cmdline |
| 617 | fi |
| 618 | |
| 619 | if [ "$QUIET" = "n" ]; then |
| 620 | adb push $cmdfile $DEX_LOCATION/cmdline.sh |
| 621 | else |
| 622 | adb push $cmdfile $DEX_LOCATION/cmdline.sh > /dev/null 2>&1 |
| 623 | fi |
| 624 | |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 625 | if [ "$DRY_RUN" != "y" ]; then |
| 626 | adb shell sh $DEX_LOCATION/cmdline.sh |
| 627 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 628 | |
| 629 | rm -f $cmdfile |
| 630 | else |
| 631 | export ANDROID_PRINTF_LOG=brief |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 632 | |
| 633 | # By default, and for prebuild dex2oat, we are interested in errors being logged. In dev mode |
| 634 | # we want debug messages. |
Wojciech Staszkiewicz | d7a819a | 2016-09-01 14:43:39 -0700 | [diff] [blame] | 635 | if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then |
| 636 | if [ "$DEV_MODE" = "y" ]; then |
| 637 | export ANDROID_LOG_TAGS='*:d' |
| 638 | else |
| 639 | export ANDROID_LOG_TAGS='*:e' |
| 640 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 641 | fi |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 642 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 643 | export ANDROID_DATA="$DEX_LOCATION" |
Nicolas Geoffray | 8eedb47 | 2014-10-29 14:05:59 +0000 | [diff] [blame] | 644 | export ANDROID_ROOT="${ANDROID_ROOT}" |
Colin Cross | afd3c9e | 2016-09-16 13:47:21 -0700 | [diff] [blame] | 645 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
| 646 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/${LIBRARY_DIRECTORY}:${ANDROID_ROOT}/${TEST_DIRECTORY}" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 647 | export PATH="$PATH:${ANDROID_ROOT}/bin" |
| 648 | |
David Srbecky | c9ede38 | 2015-06-20 06:03:53 +0100 | [diff] [blame] | 649 | # Temporarily disable address space layout randomization (ASLR). |
| 650 | # This is needed on the host so that the linker loads core.oat at the necessary address. |
| 651 | export LD_USE_LOAD_BIAS=1 |
| 652 | |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 653 | cmdline="$dalvikvm_cmdline" |
| 654 | |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 655 | if [ "$TIME_OUT" = "gdb" ]; then |
| 656 | if [ `uname` = "Darwin" ]; then |
| 657 | # Fall back to timeout on Mac. |
| 658 | TIME_OUT="timeout" |
Hiroshi Yamauchi | c823eff | 2015-09-01 16:21:35 -0700 | [diff] [blame] | 659 | elif [ "$ISA" = "x86" ]; then |
| 660 | # prctl call may fail in 32-bit on an older (3.2) 64-bit Linux kernel. Fall back to timeout. |
| 661 | TIME_OUT="timeout" |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 662 | else |
| 663 | # Check if gdb is available. |
| 664 | gdb --eval-command="quit" > /dev/null 2>&1 |
| 665 | if [ $? != 0 ]; then |
| 666 | # gdb isn't available. Fall back to timeout. |
| 667 | TIME_OUT="timeout" |
| 668 | fi |
| 669 | fi |
| 670 | fi |
| 671 | |
| 672 | if [ "$TIME_OUT" = "timeout" ]; then |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 673 | # Add timeout command if time out is desired. |
Andreas Gampe | 038bb22 | 2015-01-13 19:48:14 -0800 | [diff] [blame] | 674 | # |
Andreas Gampe | 6fb9256 | 2016-08-01 21:53:57 -0700 | [diff] [blame] | 675 | # Note: We first send SIGRTMIN+2 (usually 36) to ART, which will induce a full thread dump |
| 676 | # before abort. However, dumping threads might deadlock, so we also use the "-k" |
| 677 | # option to definitely kill the child. |
| 678 | cmdline="timeout -k 120s -s SIGRTMIN+2 ${TIME_OUT_VALUE}s $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 679 | fi |
| 680 | |
| 681 | if [ "$DEV_MODE" = "y" ]; then |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 682 | echo "mkdir -p ${mkdir_locations} && $dex2oat_cmdline && $vdex_cmdline && $strip_cmdline && $cmdline" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 683 | fi |
| 684 | |
| 685 | cd $ANDROID_BUILD_TOP |
| 686 | |
David Srbecky | 2e4afe8 | 2016-01-27 18:42:06 +0000 | [diff] [blame] | 687 | rm -rf ${DEX_LOCATION}/dalvik-cache/ |
Alex Light | afb5d19 | 2016-05-24 15:57:45 -0700 | [diff] [blame] | 688 | mkdir -p ${mkdir_locations} || exit 1 |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 689 | $dex2oat_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
Nicolas Geoffray | b0bbe8e | 2016-11-19 10:42:37 +0000 | [diff] [blame] | 690 | $vdex_cmdline || { echo "Dex2oat failed." >&2 ; exit 2; } |
Richard Uhler | 76f5cb6 | 2016-04-04 13:30:16 -0700 | [diff] [blame] | 691 | $strip_cmdline || { echo "Strip failed." >&2 ; exit 3; } |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 692 | |
| 693 | # For running, we must turn off logging when dex2oat or patchoat are missing. Otherwise we use |
| 694 | # 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] | 695 | if [ "$EXTERNAL_LOG_TAGS" = "n" ]; then |
| 696 | if [ "$DEV_MODE" = "y" ]; then |
| 697 | export ANDROID_LOG_TAGS='*:d' |
| 698 | elif [ "$USE_DEX2OAT_AND_PATCHOAT" = "n" ]; then |
| 699 | # All tests would log the error of failing dex2oat/patchoat. Be silent here and only |
| 700 | # log fatal events. |
| 701 | export ANDROID_LOG_TAGS='*:s' |
| 702 | else |
| 703 | # We are interested in LOG(ERROR) output. |
| 704 | export ANDROID_LOG_TAGS='*:e' |
| 705 | fi |
| 706 | fi |
| 707 | |
| 708 | if [ "$DRY_RUN" = "y" ]; then |
| 709 | exit 0 |
Andreas Gampe | a878082 | 2015-03-13 19:51:09 -0700 | [diff] [blame] | 710 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 711 | |
| 712 | if [ "$USE_GDB" = "y" ]; then |
| 713 | # When running under gdb, we cannot do piping and grepping... |
Dmitriy Ivanov | f57874d | 2014-10-07 13:43:23 -0700 | [diff] [blame] | 714 | $cmdline "$@" |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 715 | else |
Hiroshi Yamauchi | 6ffb9cc | 2015-08-31 15:14:17 -0700 | [diff] [blame] | 716 | if [ "$TIME_OUT" != "gdb" ]; then |
| 717 | trap 'kill -INT -$pid' INT |
| 718 | $cmdline "$@" 2>&1 & pid=$! |
| 719 | wait $pid |
| 720 | # Add extra detail if time out is enabled. |
| 721 | if [ ${PIPESTATUS[0]} = 124 ] && [ "$TIME_OUT" = "timeout" ]; then |
| 722 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 723 | fi |
| 724 | else |
| 725 | # With a thread dump that uses gdb if a timeout. |
| 726 | trap 'kill -INT -$pid' INT |
| 727 | $cmdline "$@" 2>&1 & pid=$! |
| 728 | # Spawn a watcher process. |
| 729 | ( sleep $TIME_OUT_VALUE && \ |
| 730 | echo "##### Thread dump using gdb on test timeout" && \ |
| 731 | ( gdb -q -p $pid --eval-command="info thread" --eval-command="thread apply all bt" \ |
| 732 | --eval-command="call exit(124)" --eval-command=quit || \ |
| 733 | kill $pid )) 2> /dev/null & watcher=$! |
| 734 | wait $pid |
| 735 | test_exit_status=$? |
| 736 | pkill -P $watcher 2> /dev/null # kill the sleep which will in turn end the watcher as well |
| 737 | if [ $test_exit_status = 0 ]; then |
| 738 | # The test finished normally. |
| 739 | exit 0 |
| 740 | else |
| 741 | # The test failed or timed out. |
| 742 | if [ $test_exit_status = 124 ]; then |
| 743 | # The test timed out. |
| 744 | echo -e "\e[91mTEST TIMED OUT!\e[0m" >&2 |
| 745 | fi |
| 746 | fi |
Nicolas Geoffray | 1a58b7f | 2014-10-06 12:23:04 +0100 | [diff] [blame] | 747 | fi |
| 748 | fi |
| 749 | fi |