blob: f8f393f9319b73fad56a3c8a95068fe32ad8cdb7 [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.
jeffhao5d1ac922011-09-29 17:41:15 -07005
6msg() {
7 if [ "$QUIET" = "n" ]; then
8 echo "$@"
9 fi
10}
11
jeffhao5d1ac922011-09-29 17:41:15 -070012DEBUG="n"
13GDB="n"
jeffhao0dff3f42012-11-20 15:13:43 -080014INTERPRETER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070015VERIFY="y"
16OPTIMIZE="y"
Elliott Hughes7c046102011-10-19 18:16:03 -070017INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070018DEV_MODE="n"
19QUIET="n"
Ian Rogers6950e652012-08-28 18:20:00 -070020OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070021
22while true; do
23 if [ "x$1" = "x--quiet" ]; then
24 QUIET="y"
25 shift
Ian Rogers6950e652012-08-28 18:20:00 -070026 elif [ "x$1" = "x-O" ]; then
27 OATEXEC="oatexec"
28 shift
jeffhao5d1ac922011-09-29 17:41:15 -070029 elif [ "x$1" = "x--debug" ]; then
30 DEBUG="y"
31 shift
32 elif [ "x$1" = "x--gdb" ]; then
33 GDB="y"
Ian Rogers6030ef42013-02-20 14:15:53 -080034 DEV_MODE="y"
jeffhao5d1ac922011-09-29 17:41:15 -070035 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070036 elif [ "x$1" = "x--invoke-with" ]; then
37 shift
Ian Rogers0e033672013-04-19 10:22:46 -070038 if [ "x$INVOKE_WITH" = "x" ]; then
39 INVOKE_WITH="$1"
40 else
41 INVOKE_WITH="$INVOKE_WITH $1"
42 fi
jeffhao5d1ac922011-09-29 17:41:15 -070043 shift
44 elif [ "x$1" = "x--dev" ]; then
45 DEV_MODE="y"
46 shift
jeffhao0dff3f42012-11-20 15:13:43 -080047 elif [ "x$1" = "x--interpreter" ]; then
48 INTERPRETER="y"
49 shift
jeffhao5d1ac922011-09-29 17:41:15 -070050 elif [ "x$1" = "x--no-verify" ]; then
51 VERIFY="n"
52 shift
53 elif [ "x$1" = "x--no-optimize" ]; then
54 OPTIMIZE="n"
55 shift
jeffhao5d1ac922011-09-29 17:41:15 -070056 elif [ "x$1" = "x--" ]; then
57 shift
58 break
59 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070060 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070061 exit 1
62 else
63 break
64 fi
65done
66
jeffhao5d1ac922011-09-29 17:41:15 -070067msg "------------------------------"
68
Brian Carlstrom7675e162013-06-10 16:18:04 -070069mkdir $DEX_LOCATION/dalvik-cache
Brian Carlstrom105215d2012-06-14 12:50:44 -070070[[ $? -ne 0 ]] && exit
jeffhao5d1ac922011-09-29 17:41:15 -070071
72export ANDROID_PRINTF_LOG=brief
73if [ "$DEV_MODE" = "y" ]; then
74 export ANDROID_LOG_TAGS='*:d'
75else
76 export ANDROID_LOG_TAGS='*:s'
77fi
Brian Carlstrom105215d2012-06-14 12:50:44 -070078export ANDROID_DATA="$DEX_LOCATION"
Elliott Hughese7fb2a62012-04-23 12:39:12 -070079export ANDROID_ROOT="${ANDROID_HOST_OUT}"
jeffhao5d1ac922011-09-29 17:41:15 -070080export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
81export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
Brian Carlstrom2ab7f482012-06-04 15:37:25 -070082unset ANDROID_PRODUCT_OUT # avoid defaulting dex2oat --host-prefix to target output
jeffhao5d1ac922011-09-29 17:41:15 -070083
Ian Rogers6950e652012-08-28 18:20:00 -070084exe="${ANDROID_ROOT}/bin/${OATEXEC}"
jeffhao5d1ac922011-09-29 17:41:15 -070085
86if [ "$DEBUG" = "y" ]; then
87 PORT=8000
Elliott Hughes72395bf2012-04-24 13:45:26 -070088 msg "Waiting for jdb to connect:"
89 msg " jdb -attach localhost:$PORT"
90 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -070091fi
92
93if [ "$GDB" = "y" ]; then
94 gdb=gdb
Brian Carlstromebf7eab2013-03-06 15:22:27 -080095 gdbargs="--args $exe"
96 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
97 # gdbargs="--annotate=3 $gdbargs"
jeffhao5d1ac922011-09-29 17:41:15 -070098fi
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 "$@"