| #!/bin/sh |
| # |
| # Run the code in test.jar on the device. The jar should contain a top-level |
| # class named Main to run. |
| # |
| # Options: |
| # --quiet -- don't chatter |
| # --debug -- wait for debugger to attach |
| # --zygote -- use the zygote (if so, all other options are ignored) |
| # --dev -- development mode (print the vm invocation cmdline) |
| # --no-verify -- turn off verification (on by default) |
| # --no-optimize -- turn off optimization (on by default) |
| # --no-precise -- turn off precise GC (on by default) |
| |
| msg() { |
| if [ "$QUIET" = "n" ]; then |
| echo "$@" |
| fi |
| } |
| |
| DEBUG="n" |
| VERIFY="y" |
| OPTIMIZE="y" |
| ZYGOTE="n" |
| QUIET="n" |
| PRECISE="y" |
| DEV_MODE="n" |
| |
| while true; do |
| if [ "x$1" = "x--quiet" ]; then |
| QUIET="y" |
| shift |
| elif [ "x$1" = "x--debug" ]; then |
| DEBUG="y" |
| shift |
| elif [ "x$1" = "x--zygote" ]; then |
| ZYGOTE="y" |
| msg "Spawning from zygote" |
| shift |
| elif [ "x$1" = "x--dev" ]; then |
| DEV_MODE="y" |
| shift |
| elif [ "x$1" = "x--no-verify" ]; then |
| VERIFY="n" |
| shift |
| elif [ "x$1" = "x--no-optimize" ]; then |
| OPTIMIZE="n" |
| shift |
| elif [ "x$1" = "x--no-precise" ]; then |
| PRECISE="n" |
| shift |
| elif [ "x$1" = "x--" ]; then |
| shift |
| break |
| elif expr "x$1" : "x--" >/dev/null 2>&1; then |
| echo "unknown option: $1" 1>&2 |
| exit 1 |
| else |
| break |
| fi |
| done |
| |
| if [ "$ZYGOTE" = "n" ]; then |
| if [ "$OPTIMIZE" = "y" ]; then |
| if [ "$VERIFY" = "y" ]; then |
| DEX_OPTIMIZE="-Xdexopt:verified" |
| else |
| DEX_OPTIMIZE="-Xdexopt:all" |
| fi |
| msg "Performing optimizations" |
| else |
| DEX_OPTIMIZE="-Xdexopt:none" |
| msg "Skipping optimizations" |
| fi |
| |
| if [ "$VERIFY" = "y" ]; then |
| DEX_VERIFY="" |
| msg "Performing verification" |
| else |
| DEX_VERIFY="-Xverify:none" |
| msg "Skipping verification" |
| fi |
| fi |
| |
| msg "------------------------------" |
| |
| if [ "$QUIET" = "n" ]; then |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar /system/framework |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat /system/framework |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art /system/framework |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar /system/framework |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.oat /system/framework |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.art /system/framework |
| else |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.jar /system/framework >/dev/null 2>&1 |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.oat /system/framework >/dev/null 2>&1 |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME.art /system/framework >/dev/null 2>&1 |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.jar /system/framework >/dev/null 2>&1 |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.oat /system/framework >/dev/null 2>&1 |
| adb push ${ANDROID_PRODUCT_OUT}/system/framework/$TEST_NAME-ex.art /system/framework >/dev/null 2>&1 |
| fi |
| |
| if [ "$DEBUG" = "y" ]; then |
| DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" |
| fi |
| |
| if [ "$PRECISE" = "y" ]; then |
| GC_OPTS="-Xgc:precise -Xgenregmap" |
| else |
| GC_OPTS="-Xgc:noprecise" |
| fi |
| |
| if [ "$ZYGOTE" = "y" ]; then |
| adb shell cd /data \; dvz -classpath $TEST_NAME.jar Main "$@" |
| else |
| cmdline="cd /data; oatexecd \ |
| -Ximage:/system/framework/core.art \ |
| -cp /system/framework/$TEST_NAME.jar \ |
| Main" |
| #cmdline="cd /data; dalvikvm $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG \ |
| # $GC_OPTS -cp test.jar -Xint:${INTERP} -ea Main" |
| if [ "$DEV_MODE" = "y" ]; then |
| echo $cmdline "$@" |
| fi |
| |
| adb shell $cmdline "$@" |
| fi |