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