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