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) |
Ian Rogers | 7769f50 | 2012-02-03 18:02:28 -0800 | [diff] [blame] | 14 | # -O -- run non-debug code |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 15 | |
| 16 | msg() { |
| 17 | if [ "$QUIET" = "n" ]; then |
| 18 | echo "$@" |
| 19 | fi |
| 20 | } |
| 21 | |
Ian Rogers | 7769f50 | 2012-02-03 18:02:28 -0800 | [diff] [blame] | 22 | OATEXEC="oatexecd" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 23 | DEBUG="n" |
| 24 | VERIFY="y" |
| 25 | OPTIMIZE="y" |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 26 | ZYGOTE="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 27 | QUIET="n" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 28 | DEV_MODE="n" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 29 | INVOKE_WITH="" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 30 | |
| 31 | while true; do |
| 32 | if [ "x$1" = "x--quiet" ]; then |
| 33 | QUIET="y" |
| 34 | shift |
Ian Rogers | 7769f50 | 2012-02-03 18:02:28 -0800 | [diff] [blame] | 35 | elif [ "x$1" = "x-O" ]; then |
| 36 | OATEXEC="oatexec" |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 37 | shift |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 38 | elif [ "x$1" = "x--debug" ]; then |
| 39 | DEBUG="y" |
| 40 | shift |
| 41 | elif [ "x$1" = "x--zygote" ]; then |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 42 | ZYGOTE="--zygote" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 43 | msg "Spawning from zygote" |
| 44 | shift |
| 45 | elif [ "x$1" = "x--dev" ]; then |
| 46 | DEV_MODE="y" |
| 47 | shift |
Elliott Hughes | 7c04610 | 2011-10-19 18:16:03 -0700 | [diff] [blame] | 48 | elif [ "x$1" = "x--invoke-with" ]; then |
| 49 | shift |
| 50 | INVOKE_WITH="$1" |
| 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 | |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 69 | if [ "$ZYGOTE" = "" ]; then |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 70 | if [ "$OPTIMIZE" = "y" ]; then |
| 71 | if [ "$VERIFY" = "y" ]; then |
| 72 | DEX_OPTIMIZE="-Xdexopt:verified" |
| 73 | else |
| 74 | DEX_OPTIMIZE="-Xdexopt:all" |
| 75 | fi |
| 76 | msg "Performing optimizations" |
| 77 | else |
| 78 | DEX_OPTIMIZE="-Xdexopt:none" |
| 79 | msg "Skipping optimizations" |
| 80 | fi |
| 81 | |
| 82 | if [ "$VERIFY" = "y" ]; then |
| 83 | DEX_VERIFY="" |
| 84 | msg "Performing verification" |
| 85 | else |
| 86 | DEX_VERIFY="-Xverify:none" |
| 87 | msg "Skipping verification" |
| 88 | fi |
| 89 | fi |
| 90 | |
| 91 | msg "------------------------------" |
| 92 | |
| 93 | if [ "$QUIET" = "n" ]; then |
Brian Carlstrom | 78325a4 | 2012-03-06 22:56:41 -0800 | [diff] [blame] | 94 | adb shell mkdir /data/run-test |
Brian Carlstrom | 904667a | 2012-03-10 23:43:07 -0800 | [diff] [blame] | 95 | adb push $TEST_NAME.jar /data/run-test |
| 96 | adb push $TEST_NAME.jar.oat /data/run-test |
| 97 | adb push $TEST_NAME-ex.jar /data/run-test |
| 98 | adb push $TEST_NAME-ex.jar.oat /data/run-test |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 99 | else |
Brian Carlstrom | 78325a4 | 2012-03-06 22:56:41 -0800 | [diff] [blame] | 100 | adb shell mkdir /data/run-test >/dev/null 2>&1 |
Brian Carlstrom | 904667a | 2012-03-10 23:43:07 -0800 | [diff] [blame] | 101 | adb push $TEST_NAME.jar /data/run-test >/dev/null 2>&1 |
| 102 | adb push $TEST_NAME.jar.oat /data/run-test >/dev/null 2>&1 |
| 103 | adb push $TEST_NAME-ex.jar /data/run-test >/dev/null 2>&1 |
| 104 | adb push $TEST_NAME-ex.jar.oat /data/run-test >/dev/null 2>&1 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 105 | fi |
| 106 | |
| 107 | if [ "$DEBUG" = "y" ]; then |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 108 | # This is for ddms: |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 109 | #DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" |
Elliott Hughes | d1cc836 | 2011-10-24 16:58:50 -0700 | [diff] [blame] | 110 | # Connect by running 'ddms'. |
| 111 | |
| 112 | # This is for jdb: |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 113 | 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] | 114 | # Connect thus: |
| 115 | # adb forward tcp:12345 tcp:12345 |
| 116 | # jdb -attach localhost:12345 |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 117 | fi |
| 118 | |
TDYa127 | 6ce558b | 2012-04-11 11:17:55 -0700 | [diff] [blame] | 119 | cmdline="cd /data; export DEX_LOCATION=$DEX_LOCATION; $INVOKE_WITH $OATEXEC $DEX_DEBUG $ZYGOTE -Xjnigreflimit:256 \ |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 120 | -Ximage:/data/art-test/core.art \ |
Brian Carlstrom | 78325a4 | 2012-03-06 22:56:41 -0800 | [diff] [blame] | 121 | -cp /data/run-test/$TEST_NAME.jar \ |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 122 | Main" |
| 123 | if [ "$DEV_MODE" = "y" ]; then |
| 124 | echo $cmdline "$@" |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 125 | fi |
Elliott Hughes | 58bcc40 | 2012-02-14 14:10:10 -0800 | [diff] [blame] | 126 | |
| 127 | adb shell $cmdline "$@" |