jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Run the code in test.jar using the host-mode virtual machine. The jar should |
| 4 | # contain a top-level class named Main to run. |
| 5 | # |
| 6 | # Options: |
| 7 | # --quiet -- don't chatter |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 8 | # --debug -- wait for debugger to attach |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 9 | # --no-verify -- turn off verification (on by default) |
| 10 | # --no-optimize -- turn off optimization (on by default) |
| 11 | |
| 12 | msg() { |
| 13 | if [ "$QUIET" = "n" ]; then |
| 14 | echo "$@" |
| 15 | fi |
| 16 | } |
| 17 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 18 | DEBUG="n" |
| 19 | GDB="n" |
| 20 | VERIFY="y" |
| 21 | OPTIMIZE="y" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 22 | INVOKE_WITH="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 23 | DEV_MODE="n" |
| 24 | QUIET="n" |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 25 | OATEXEC="oatexecd" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 26 | |
| 27 | while true; do |
| 28 | if [ "x$1" = "x--quiet" ]; then |
| 29 | QUIET="y" |
| 30 | shift |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 31 | elif [ "x$1" = "x-O" ]; then |
| 32 | OATEXEC="oatexec" |
| 33 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 34 | elif [ "x$1" = "x--debug" ]; then |
| 35 | DEBUG="y" |
| 36 | shift |
| 37 | elif [ "x$1" = "x--gdb" ]; then |
| 38 | GDB="y" |
| 39 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 40 | elif [ "x$1" = "x--invoke-with" ]; then |
| 41 | shift |
| 42 | INVOKE_WITH="$1" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 43 | shift |
| 44 | elif [ "x$1" = "x--dev" ]; then |
| 45 | DEV_MODE="y" |
| 46 | shift |
| 47 | elif [ "x$1" = "x--no-verify" ]; then |
| 48 | VERIFY="n" |
| 49 | shift |
| 50 | elif [ "x$1" = "x--no-optimize" ]; then |
| 51 | OPTIMIZE="n" |
| 52 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 53 | elif [ "x$1" = "x--" ]; then |
| 54 | shift |
| 55 | break |
| 56 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 57 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 58 | exit 1 |
| 59 | else |
| 60 | break |
| 61 | fi |
| 62 | done |
| 63 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 64 | msg "------------------------------" |
| 65 | |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 66 | mkdir $DEX_LOCATION/art-cache |
| 67 | [[ $? -ne 0 ]] && exit |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 68 | |
| 69 | export ANDROID_PRINTF_LOG=brief |
| 70 | if [ "$DEV_MODE" = "y" ]; then |
| 71 | export ANDROID_LOG_TAGS='*:d' |
| 72 | else |
| 73 | export ANDROID_LOG_TAGS='*:s' |
| 74 | fi |
Brian Carlstrom | 105215d | 2012-06-14 12:50:44 -0700 | [diff] [blame] | 75 | export ANDROID_DATA="$DEX_LOCATION" |
Elliott Hughes | e7fb2a6 | 2012-04-23 12:39:12 -0700 | [diff] [blame] | 76 | export ANDROID_ROOT="${ANDROID_HOST_OUT}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 77 | export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
| 78 | export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib" |
Brian Carlstrom | 2ab7f48 | 2012-06-04 15:37:25 -0700 | [diff] [blame] | 79 | unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 80 | |
Ian Rogers | 6950e65 | 2012-08-28 18:20:00 -0700 | [diff] [blame] | 81 | exe="${ANDROID_ROOT}/bin/${OATEXEC}" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 82 | |
| 83 | if [ "$DEBUG" = "y" ]; then |
| 84 | PORT=8000 |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 85 | msg "Waiting for jdb to connect:" |
| 86 | msg " jdb -attach localhost:$PORT" |
| 87 | DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 88 | fi |
| 89 | |
| 90 | if [ "$GDB" = "y" ]; then |
| 91 | gdb=gdb |
| 92 | gdbargs="--args $exe" |
| 93 | fi |
| 94 | |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 95 | JNI_OPTS="-Xjnigreflimit:256 -Xcheck:jni" |
| 96 | |
Brian Carlstrom | 4855cd5 | 2012-04-03 21:38:13 -0700 | [diff] [blame] | 97 | cd $ANDROID_BUILD_TOP |
| 98 | $INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \ |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 99 | $JNI_OPTS $DEBUG_OPTS \ |
TDYa127 | b92bcab | 2012-04-08 00:09:51 -0700 | [diff] [blame] | 100 | -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@" |