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