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