blob: 7154ac26fcfc1cae91092e1ac4065e4a3c0d34f0 [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001#!/bin/sh
2#
3# Run the code in test.jar on the device. The jar should contain a top-level
4# 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
9# --zygote -- use the zygote (if so, all other options are ignored)
10# --dev -- development mode (print the vm invocation cmdline)
jeffhao0dff3f42012-11-20 15:13:43 -080011# --interpreter -- enable interpreter only mode (off by default)
jeffhao5d1ac922011-09-29 17:41:15 -070012# --no-verify -- turn off verification (on by default)
13# --no-optimize -- turn off optimization (on by default)
14# --no-precise -- turn off precise GC (on by default)
Ian Rogers7769f502012-02-03 18:02:28 -080015# -O -- run non-debug code
jeffhao5d1ac922011-09-29 17:41:15 -070016
17msg() {
18 if [ "$QUIET" = "n" ]; then
19 echo "$@"
20 fi
21}
22
Ian Rogers7769f502012-02-03 18:02:28 -080023OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070024DEBUG="n"
jeffhao0dff3f42012-11-20 15:13:43 -080025INTERPRETER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070026VERIFY="y"
27OPTIMIZE="y"
Elliott Hughes58bcc402012-02-14 14:10:10 -080028ZYGOTE=""
jeffhao5d1ac922011-09-29 17:41:15 -070029QUIET="n"
jeffhao5d1ac922011-09-29 17:41:15 -070030DEV_MODE="n"
Elliott Hughes7c046102011-10-19 18:16:03 -070031INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070032
33while true; do
34 if [ "x$1" = "x--quiet" ]; then
35 QUIET="y"
36 shift
Ian Rogers7769f502012-02-03 18:02:28 -080037 elif [ "x$1" = "x-O" ]; then
38 OATEXEC="oatexec"
Elliott Hughes7c046102011-10-19 18:16:03 -070039 shift
jeffhao5d1ac922011-09-29 17:41:15 -070040 elif [ "x$1" = "x--debug" ]; then
41 DEBUG="y"
42 shift
43 elif [ "x$1" = "x--zygote" ]; then
Elliott Hughes58bcc402012-02-14 14:10:10 -080044 ZYGOTE="--zygote"
jeffhao5d1ac922011-09-29 17:41:15 -070045 msg "Spawning from zygote"
46 shift
47 elif [ "x$1" = "x--dev" ]; then
48 DEV_MODE="y"
49 shift
jeffhao0dff3f42012-11-20 15:13:43 -080050 elif [ "x$1" = "x--interpreter" ]; then
51 INTERPRETER="y"
52 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070053 elif [ "x$1" = "x--invoke-with" ]; then
54 shift
55 INVOKE_WITH="$1"
56 shift
jeffhao5d1ac922011-09-29 17:41:15 -070057 elif [ "x$1" = "x--no-verify" ]; then
58 VERIFY="n"
59 shift
60 elif [ "x$1" = "x--no-optimize" ]; then
61 OPTIMIZE="n"
62 shift
jeffhao5d1ac922011-09-29 17:41:15 -070063 elif [ "x$1" = "x--" ]; then
64 shift
65 break
66 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070067 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070068 exit 1
69 else
70 break
71 fi
72done
73
Elliott Hughes58bcc402012-02-14 14:10:10 -080074if [ "$ZYGOTE" = "" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -070075 if [ "$OPTIMIZE" = "y" ]; then
76 if [ "$VERIFY" = "y" ]; then
77 DEX_OPTIMIZE="-Xdexopt:verified"
78 else
79 DEX_OPTIMIZE="-Xdexopt:all"
80 fi
81 msg "Performing optimizations"
82 else
83 DEX_OPTIMIZE="-Xdexopt:none"
84 msg "Skipping optimizations"
85 fi
86
87 if [ "$VERIFY" = "y" ]; then
88 DEX_VERIFY=""
89 msg "Performing verification"
90 else
91 DEX_VERIFY="-Xverify:none"
92 msg "Skipping verification"
93 fi
94fi
95
96msg "------------------------------"
97
98if [ "$QUIET" = "n" ]; then
Brian Carlstrom4ec9b1f2012-06-17 22:27:43 -070099 adb shell rm -r $DEX_LOCATION
Brian Carlstrom105215d2012-06-14 12:50:44 -0700100 adb shell mkdir -p $DEX_LOCATION
101 adb push $TEST_NAME.jar $DEX_LOCATION
102 adb push $TEST_NAME-ex.jar $DEX_LOCATION
jeffhao5d1ac922011-09-29 17:41:15 -0700103else
Brian Carlstrom4ec9b1f2012-06-17 22:27:43 -0700104 adb shell rm -r $DEX_LOCATION >/dev/null 2>&1
Brian Carlstrom105215d2012-06-14 12:50:44 -0700105 adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1
106 adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1
107 adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700108fi
109
110if [ "$DEBUG" = "y" ]; then
Elliott Hughes72395bf2012-04-24 13:45:26 -0700111 # Use this instead for ddms and connect by running 'ddms':
112 # DEBUG_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
113 # TODO: add a separate --ddms option?
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700114
Elliott Hughes72395bf2012-04-24 13:45:26 -0700115 PORT=12345
116 msg "Waiting for jdb to connect:"
117 msg " adb forward tcp:$PORT tcp:$PORT"
118 msg " jdb -attach localhost:$PORT"
119 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -0700120fi
121
jeffhao0dff3f42012-11-20 15:13:43 -0800122if [ "$INTERPRETER" = "y" ]; then
123 INT_OPTS="-Xint"
124fi
125
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700126JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700127
Brian Carlstrom105215d2012-06-14 12:50:44 -0700128cmdline="cd $DEX_LOCATION && mkdir art-cache && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \
jeffhao0dff3f42012-11-20 15:13:43 -0800129 $INVOKE_WITH $OATEXEC $ZYGOTE $JNI_OPTS $INT_OPTS $DEBUG_OPTS -Ximage:/data/art-test/core.art -cp $DEX_LOCATION/$TEST_NAME.jar Main"
Elliott Hughes58bcc402012-02-14 14:10:10 -0800130if [ "$DEV_MODE" = "y" ]; then
131 echo $cmdline "$@"
jeffhao5d1ac922011-09-29 17:41:15 -0700132fi
Elliott Hughes58bcc402012-02-14 14:10:10 -0800133
134adb shell $cmdline "$@"