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