blob: 47d8c322a9167a826f4a479221143574b6cf3a3f [file] [log] [blame]
#!/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)
# -O -- run non-debug code
msg() {
if [ "$QUIET" = "n" ]; then
echo "$@"
fi
}
OATEXEC="oatexecd"
DEBUG="n"
VERIFY="y"
OPTIMIZE="y"
ZYGOTE=""
QUIET="n"
DEV_MODE="n"
INVOKE_WITH=""
while true; do
if [ "x$1" = "x--quiet" ]; then
QUIET="y"
shift
elif [ "x$1" = "x-O" ]; then
OATEXEC="oatexec"
shift
elif [ "x$1" = "x--debug" ]; then
DEBUG="y"
shift
elif [ "x$1" = "x--zygote" ]; then
ZYGOTE="--zygote"
msg "Spawning from zygote"
shift
elif [ "x$1" = "x--dev" ]; then
DEV_MODE="y"
shift
elif [ "x$1" = "x--invoke-with" ]; then
shift
INVOKE_WITH="$1"
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--" ]; then
shift
break
elif expr "x$1" : "x--" >/dev/null 2>&1; then
echo "unknown $0 option: $1" 1>&2
exit 1
else
break
fi
done
if [ "$ZYGOTE" = "" ]; 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 shell rm -r $DEX_LOCATION
adb shell mkdir -p $DEX_LOCATION
adb push $TEST_NAME.jar $DEX_LOCATION
adb push $TEST_NAME-ex.jar $DEX_LOCATION
else
adb shell rm -r $DEX_LOCATION >/dev/null 2>&1
adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1
adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1
adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1
fi
if [ "$DEBUG" = "y" ]; then
# Use this instead for ddms and connect by running 'ddms':
# DEBUG_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
# TODO: add a separate --ddms option?
PORT=12345
msg "Waiting for jdb to connect:"
msg " adb forward tcp:$PORT tcp:$PORT"
msg " jdb -attach localhost:$PORT"
DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
fi
JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
cmdline="cd $DEX_LOCATION && mkdir art-cache && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \
$INVOKE_WITH $OATEXEC $ZYGOTE $JNI_OPTS $DEBUG_OPTS -Ximage:/data/art-test/core.art -cp $DEX_LOCATION/$TEST_NAME.jar Main"
if [ "$DEV_MODE" = "y" ]; then
echo $cmdline "$@"
fi
adb shell $cmdline "$@"