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