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