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