blob: 5c9d9edbfe1f2868b965154c57172b0039c09046 [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
jeffhao0dff3f42012-11-20 15:13:43 -08009# --interpreter -- enable interpreter only mode (off by default)
jeffhao5d1ac922011-09-29 17:41:15 -070010# --no-verify -- turn off verification (on by default)
11# --no-optimize -- turn off optimization (on by default)
12
13msg() {
14 if [ "$QUIET" = "n" ]; then
15 echo "$@"
16 fi
17}
18
jeffhao5d1ac922011-09-29 17:41:15 -070019DEBUG="n"
20GDB="n"
jeffhao0dff3f42012-11-20 15:13:43 -080021INTERPRETER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070022VERIFY="y"
23OPTIMIZE="y"
Elliott Hughes7c046102011-10-19 18:16:03 -070024INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070025DEV_MODE="n"
26QUIET="n"
Ian Rogers6950e652012-08-28 18:20:00 -070027OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070028
29while true; do
30 if [ "x$1" = "x--quiet" ]; then
31 QUIET="y"
32 shift
Ian Rogers6950e652012-08-28 18:20:00 -070033 elif [ "x$1" = "x-O" ]; then
34 OATEXEC="oatexec"
35 shift
jeffhao5d1ac922011-09-29 17:41:15 -070036 elif [ "x$1" = "x--debug" ]; then
37 DEBUG="y"
38 shift
39 elif [ "x$1" = "x--gdb" ]; then
40 GDB="y"
41 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070042 elif [ "x$1" = "x--invoke-with" ]; then
43 shift
44 INVOKE_WITH="$1"
jeffhao5d1ac922011-09-29 17:41:15 -070045 shift
46 elif [ "x$1" = "x--dev" ]; then
47 DEV_MODE="y"
48 shift
jeffhao0dff3f42012-11-20 15:13:43 -080049 elif [ "x$1" = "x--interpreter" ]; then
50 INTERPRETER="y"
51 shift
jeffhao5d1ac922011-09-29 17:41:15 -070052 elif [ "x$1" = "x--no-verify" ]; then
53 VERIFY="n"
54 shift
55 elif [ "x$1" = "x--no-optimize" ]; then
56 OPTIMIZE="n"
57 shift
jeffhao5d1ac922011-09-29 17:41:15 -070058 elif [ "x$1" = "x--" ]; then
59 shift
60 break
61 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070062 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070063 exit 1
64 else
65 break
66 fi
67done
68
jeffhao5d1ac922011-09-29 17:41:15 -070069msg "------------------------------"
70
Brian Carlstrom105215d2012-06-14 12:50:44 -070071mkdir $DEX_LOCATION/art-cache
72[[ $? -ne 0 ]] && exit
jeffhao5d1ac922011-09-29 17:41:15 -070073
74export ANDROID_PRINTF_LOG=brief
75if [ "$DEV_MODE" = "y" ]; then
76 export ANDROID_LOG_TAGS='*:d'
77else
78 export ANDROID_LOG_TAGS='*:s'
79fi
Brian Carlstrom105215d2012-06-14 12:50:44 -070080export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070081export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -070082export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
83export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
Brian Carlstrom2ab7f482012-06-04 15:37:25 -070084unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
jeffhao5d1ac922011-09-29 17:41:15 -070085
Ian Rogers6950e652012-08-28 18:20:00 -070086exe="${ANDROID_ROOT}/bin/${OATEXEC}"
jeffhao5d1ac922011-09-29 17:41:15 -070087
88if [ "$DEBUG" = "y" ]; then
89 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -070090 msg "Waiting for jdb to connect:"
91 msg " jdb -attach localhost:$PORT"
92 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -070093fi
94
95if [ "$GDB" = "y" ]; then
96 gdb=gdb
97 gdbargs="--args $exe"
98fi
99
jeffhao0dff3f42012-11-20 15:13:43 -0800100if [ "$INTERPRETER" = "y" ]; then
101 INT_OPTS="-Xint"
102fi
103
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700104JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700105
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700106cd $ANDROID_BUILD_TOP
107$INVOKE_WITH $gdb $exe $gdbargs -Ximage:$ANDROID_ROOT/framework/core.art \
jeffhao0dff3f42012-11-20 15:13:43 -0800108 $JNI_OPTS $INT_OPTS $DEBUG_OPTS \
TDYa127b92bcab2012-04-08 00:09:51 -0700109 -cp $DEX_LOCATION/$TEST_NAME.jar Main "$@"