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