jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Run the code in test.jar on the device. The jar should contain a top-level |
| 4 | # 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 |
| 9 | # --zygote -- use the zygote (if so, all other options are ignored) |
| 10 | # --dev -- development mode (print the vm invocation cmdline) |
| 11 | # --no-verify -- turn off verification (on by default) |
| 12 | # --no-optimize -- turn off optimization (on by default) |
| 13 | # --no-precise -- turn off precise GC (on by default) |
| 14 | |
| 15 | msg() { |
| 16 | if [ "$QUIET" = "n" ]; then |
| 17 | echo "$@" |
| 18 | fi |
| 19 | } |
| 20 | |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 21 | OATEXEC="oatexec" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 22 | DEBUG="n" |
| 23 | VERIFY="y" |
| 24 | OPTIMIZE="y" |
| 25 | ZYGOTE="n" |
| 26 | QUIET="n" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 27 | DEV_MODE="n" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 28 | INVOKE_WITH="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 29 | |
| 30 | while true; do |
| 31 | if [ "x$1" = "x--quiet" ]; then |
| 32 | QUIET="y" |
| 33 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 34 | elif [ "x$1" = "x-d" ]; then |
| 35 | OATEXEC="oatexecd" |
| 36 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 37 | elif [ "x$1" = "x--debug" ]; then |
| 38 | DEBUG="y" |
| 39 | shift |
| 40 | elif [ "x$1" = "x--zygote" ]; then |
| 41 | ZYGOTE="y" |
| 42 | msg "Spawning from zygote" |
| 43 | shift |
| 44 | elif [ "x$1" = "x--dev" ]; then |
| 45 | DEV_MODE="y" |
| 46 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 47 | elif [ "x$1" = "x--invoke-with" ]; then |
| 48 | shift |
| 49 | INVOKE_WITH="$1" |
| 50 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 51 | elif [ "x$1" = "x--no-verify" ]; then |
| 52 | VERIFY="n" |
| 53 | shift |
| 54 | elif [ "x$1" = "x--no-optimize" ]; then |
| 55 | OPTIMIZE="n" |
| 56 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 57 | elif [ "x$1" = "x--" ]; then |
| 58 | shift |
| 59 | break |
| 60 | elif expr "x$1" : "x--" >/dev/null 2>&1; then |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 61 | echo "unknown $0 option: $1" 1>&2 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 62 | exit 1 |
| 63 | else |
| 64 | break |
| 65 | fi |
| 66 | done |
| 67 | |
| 68 | if [ "$ZYGOTE" = "n" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 69 | if [ "$OPTIMIZE" = "y" ]; then |
| 70 | if [ "$VERIFY" = "y" ]; then |
| 71 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 72 | else |
| 73 | DEX_OPTIMIZE="-Xdexopt:all" |
| 74 | fi |
| 75 | msg "Performing optimizations" |
| 76 | else |
| 77 | DEX_OPTIMIZE="-Xdexopt:none" |
| 78 | msg "Skipping optimizations" |
| 79 | fi |
| 80 | |
| 81 | if [ "$VERIFY" = "y" ]; then |
| 82 | DEX_VERIFY="" |
| 83 | msg "Performing verification" |
| 84 | else |
| 85 | DEX_VERIFY="-Xverify:none" |
| 86 | msg "Skipping verification" |
| 87 | fi |
| 88 | fi |
| 89 | |
| 90 | msg "------------------------------" |
| 91 | |
| 92 | if [ "$QUIET" = "n" ]; then |
Elliott Hughes | 37476bd | 2012-02-01 12:07:37 -0800 | [diff] [blame] | 93 | adb shell mkdir /data/art-test |
| 94 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar /data/art-test |
| 95 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar.oat /data/art-test |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 96 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME-ex.jar /data/art-test |
Elliott Hughes | 37476bd | 2012-02-01 12:07:37 -0800 | [diff] [blame] | 97 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME-ex.jar.oat /data/art-test |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 98 | else |
Elliott Hughes | 37476bd | 2012-02-01 12:07:37 -0800 | [diff] [blame] | 99 | adb shell mkdir /data/art-test >/dev/null 2>&1 |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 100 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar /data/art-test >/dev/null 2>&1 |
Elliott Hughes | 37476bd | 2012-02-01 12:07:37 -0800 | [diff] [blame] | 101 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME.jar.oat /data/art-test >/dev/null 2>&1 |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 102 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME-ex.jar /data/art-test >/dev/null 2>&1 |
Elliott Hughes | 37476bd | 2012-02-01 12:07:37 -0800 | [diff] [blame] | 103 | adb push ${ANDROID_PRODUCT_OUT}/data/art-test/$TEST_NAME-ex.jar.oat /data/art-test >/dev/null 2>&1 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 104 | fi |
| 105 | |
| 106 | if [ "$DEBUG" = "y" ]; then |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 107 | # This is for ddms: |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 108 | #DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 109 | # Connect by running 'ddms'. |
| 110 | |
| 111 | # This is for jdb: |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 112 | DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,address=12345,server=y,suspend=y" |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 113 | # Connect thus: |
| 114 | # adb forward tcp:12345 tcp:12345 |
| 115 | # jdb -attach localhost:12345 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 116 | fi |
| 117 | |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 118 | if [ "$ZYGOTE" = "y" ]; then |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 119 | adb shell cd /data \; dvz -classpath $TEST_NAME.jar Main "$@" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 120 | else |
Elliott Hughes | 3bb8156 | 2011-10-21 18:52:59 -0700 | [diff] [blame] | 121 | cmdline="cd /data; $INVOKE_WITH $OATEXEC ${DEX_DEBUG} -Xjnigreflimit:256 \ |
Brian Carlstrom | 47a0d5a | 2011-10-12 21:20:05 -0700 | [diff] [blame] | 122 | -Ximage:/data/art-test/core.art \ |
| 123 | -cp /data/art-test/$TEST_NAME.jar \ |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 124 | Main" |
| 125 | #cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \ |
Elliott Hughes | bb1e8f0 | 2011-10-18 14:14:25 -0700 | [diff] [blame] | 126 | # -cp test.jar -Xint:${INTERP} -ea Main" |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 127 | if [ "$DEV_MODE" = "y" ]; then |
| 128 | echo $cmdline "$@" |
| 129 | fi |
jeffhao | 795d78f | 2011-09-30 18:34:35 -0700 | [diff] [blame] | 130 | |
Elliott Hughes | 8cbc8bc | 2011-10-04 11:19:45 -0700 | [diff] [blame] | 131 | adb shell $cmdline "$@" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 132 | fi |