blob: b56549e4837debd96699c86f2257c81323dfe1d6 [file] [log] [blame]
#!/bin/sh
#
# Run the code in test.jar using the host-mode virtual machine. The jar should
# contain a top-level class named Main to run.
#
# Options:
# --quiet -- don't chatter
# --debug -- wait for debugger to attach
# --no-verify -- turn off verification (on by default)
# --no-optimize -- turn off optimization (on by default)
msg() {
if [ "$QUIET" = "n" ]; then
echo "$@"
fi
}
DEBUG="n"
GDB="n"
VERIFY="y"
OPTIMIZE="y"
INVOKE_WITH=""
DEV_MODE="n"
QUIET="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--gdb" ]; then
GDB="y"
shift
elif [ "x$1" = "x--invoke-with" ]; then
shift
INVOKE_WITH="$1"
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--" ]; 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
msg "------------------------------"
HOSTBASE="${ANDROID_BUILD_TOP}/out/host"
DATA_DIR=/tmp
DEBUG_OPTS="-Xcheck:jni"
if [ ! -d $DATA_DIR/art-cache ]; then
mkdir -p $DATA_DIR/art-cache
[[ $? -ne 0 ]] && exit
fi
export ANDROID_PRINTF_LOG=brief
if [ "$DEV_MODE" = "y" ]; then
export ANDROID_LOG_TAGS='*:d'
else
export ANDROID_LOG_TAGS='*:s'
fi
export ANDROID_DATA="$DATA_DIR"
export ANDROID_ROOT="${HOSTBASE}/linux-x86"
export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
exe="${ANDROID_ROOT}/bin/oatexecd"
if [ "$DEBUG" = "y" ]; then
PORT=8000
msg "Waiting for debugger to connect on localhost:$PORT"
# This is for jdb:
DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
# Connect thus:
# jdb -attach localhost:12345
fi
if [ "$GDB" = "y" ]; then
gdb=gdb
gdbargs="--args $exe"
fi
cd $ANDROID_BUILD_TOP
$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
$DEBUG_OPTS $DEX_DEBUG -verbose:log-to=$DEX_LOCATION/log.txt\
-cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"