blob: dee81489de2c521c94c6e07c6d0e621232865aad [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/bin/sh
2#
3# Run the code in test.jar using the host-mode virtual machine. The jar should
4# contain a top-level class named Main to run.
5#
6# Options:
7# --quiet -- don't chatter
jeffhao5d1ac922011-09-29 17:41:15 -07008# --debug -- wait for debugger to attach
jeffhao5d1ac922011-09-29 17:41:15 -07009# --no-verify -- turn off verification (on by default)
10# --no-optimize -- turn off optimization (on by default)
11
12msg() {
13 if [ "$QUIET" = "n" ]; then
14 echo "$@"
15 fi
16}
17
jeffhao5d1ac922011-09-29 17:41:15 -070018DEBUG="n"
19GDB="n"
20VERIFY="y"
21OPTIMIZE="y"
Elliott Hughes7c046102011-10-19 18:16:03 -070022INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070023DEV_MODE="n"
24QUIET="n"
Ian Rogers6950e652012-08-28 18:20:00 -070025OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070026
27while true; do
28 if [ "x$1" = "x--quiet" ]; then
29 QUIET="y"
30 shift
Ian Rogers6950e652012-08-28 18:20:00 -070031 elif [ "x$1" = "x-O" ]; then
32 OATEXEC="oatexec"
33 shift
jeffhao5d1ac922011-09-29 17:41:15 -070034 elif [ "x$1" = "x--debug" ]; then
35 DEBUG="y"
36 shift
37 elif [ "x$1" = "x--gdb" ]; then
38 GDB="y"
39 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070040 elif [ "x$1" = "x--invoke-with" ]; then
41 shift
42 INVOKE_WITH="$1"
jeffhao5d1ac922011-09-29 17:41:15 -070043 shift
44 elif [ "x$1" = "x--dev" ]; then
45 DEV_MODE="y"
46 shift
47 elif [ "x$1" = "x--no-verify" ]; then
48 VERIFY="n"
49 shift
50 elif [ "x$1" = "x--no-optimize" ]; then
51 OPTIMIZE="n"
52 shift
jeffhao5d1ac922011-09-29 17:41:15 -070053 elif [ "x$1" = "x--" ]; then
54 shift
55 break
56 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070057 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070058 exit 1
59 else
60 break
61 fi
62done
63
jeffhao5d1ac922011-09-29 17:41:15 -070064msg "------------------------------"
65
Brian Carlstrom105215d2012-06-14 12:50:44 -070066mkdir $DEX_LOCATION/art-cache
67[[ $? -ne 0 ]] && exit
jeffhao5d1ac922011-09-29 17:41:15 -070068
69export ANDROID_PRINTF_LOG=brief
70if [ "$DEV_MODE" = "y" ]; then
71 export ANDROID_LOG_TAGS='*:d'
72else
73 export ANDROID_LOG_TAGS='*:s'
74fi
Brian Carlstrom105215d2012-06-14 12:50:44 -070075export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070076export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -070077export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
78export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
Brian Carlstrom2ab7f482012-06-04 15:37:25 -070079unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
jeffhao5d1ac922011-09-29 17:41:15 -070080
Ian Rogers6950e652012-08-28 18:20:00 -070081exe="${ANDROID_ROOT}/bin/${OATEXEC}"
jeffhao5d1ac922011-09-29 17:41:15 -070082
83if [ "$DEBUG" = "y" ]; then
84 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -070085 msg "Waiting for jdb to connect:"
86 msg " jdb -attach localhost:$PORT"
87 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -070088fi
89
90if [ "$GDB" = "y" ]; then
91 gdb=gdb
92 gdbargs="--args $exe"
93fi
94
Elliott Hughes72395bf2012-04-24 13:45:26 -070095JNI_OPTS="-Xjnigreflimit:256 -Xcheck:jni"
96
Brian Carlstrom4855cd52012-04-03 21:38:13 -070097cd $ANDROID_BUILD_TOP
98$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
Elliott Hughes72395bf2012-04-24 13:45:26 -070099 $JNI_OPTS $DEBUG_OPTS \
TDYa127b92bcab2012-04-08 00:09:51 -0700100 -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"