blob: b892ce925813a697e10f68735f8b7ea308926d92 [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"
jeffhao5d1ac922011-09-29 17:41:15 -070025
26while true; do
27 if [ "x$1" = "x--quiet" ]; then
28 QUIET="y"
29 shift
jeffhao5d1ac922011-09-29 17:41:15 -070030 elif [ "x$1" = "x--debug" ]; then
31 DEBUG="y"
32 shift
33 elif [ "x$1" = "x--gdb" ]; then
34 GDB="y"
35 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070036 elif [ "x$1" = "x--invoke-with" ]; then
37 shift
38 INVOKE_WITH="$1"
jeffhao5d1ac922011-09-29 17:41:15 -070039 shift
40 elif [ "x$1" = "x--dev" ]; then
41 DEV_MODE="y"
42 shift
43 elif [ "x$1" = "x--no-verify" ]; then
44 VERIFY="n"
45 shift
46 elif [ "x$1" = "x--no-optimize" ]; then
47 OPTIMIZE="n"
48 shift
jeffhao5d1ac922011-09-29 17:41:15 -070049 elif [ "x$1" = "x--" ]; then
50 shift
51 break
52 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070053 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070054 exit 1
55 else
56 break
57 fi
58done
59
jeffhao5d1ac922011-09-29 17:41:15 -070060msg "------------------------------"
61
jeffhao5d1ac922011-09-29 17:41:15 -070062DATA_DIR=/tmp
TDYa127b92bcab2012-04-08 00:09:51 -070063DEBUG_OPTS="-Xcheck:jni"
jeffhao5d1ac922011-09-29 17:41:15 -070064
Brian Carlstrom4855cd52012-04-03 21:38:13 -070065if [ ! -d $DATA_DIR/art-cache ]; then
66 mkdir -p $DATA_DIR/art-cache
jeffhao5d1ac922011-09-29 17:41:15 -070067 [[ $? -ne 0 ]] && exit
68fi
69
70export ANDROID_PRINTF_LOG=brief
71if [ "$DEV_MODE" = "y" ]; then
72 export ANDROID_LOG_TAGS='*:d'
73else
74 export ANDROID_LOG_TAGS='*:s'
75fi
76export ANDROID_DATA="$DATA_DIR"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070077export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -070078export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
79export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
80
Brian Carlstrom4855cd52012-04-03 21:38:13 -070081exe="${ANDROID_ROOT}/bin/oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070082
83if [ "$DEBUG" = "y" ]; then
84 PORT=8000
85 msg "Waiting for debugger to connect on localhost:$PORT"
TDYa127b92bcab2012-04-08 00:09:51 -070086 # This is for jdb:
87 DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
88 # Connect thus:
89 # jdb -attach localhost:12345
jeffhao5d1ac922011-09-29 17:41:15 -070090fi
91
92if [ "$GDB" = "y" ]; then
93 gdb=gdb
94 gdbargs="--args $exe"
95fi
96
Brian Carlstrom4855cd52012-04-03 21:38:13 -070097cd $ANDROID_BUILD_TOP
98$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
TDYa127b92bcab2012-04-08 00:09:51 -070099 $DEBUG_OPTS $DEX_DEBUG -verbose:log-to=$DEX_LOCATION/log.txt\
100 -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"