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