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