blob: ce80ae45cd2ef4aa82a5c4e404d3788cb0f48375 [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.
jeffhao5d1ac922011-09-29 17:41:15 -07005
6msg() {
7 if [ "$QUIET" = "n" ]; then
8 echo "$@"
9 fi
10}
11
Ian Rogers7769f502012-02-03 18:02:28 -080012OATEXEC="oatexecd"
Ian Rogers4c1bf1a2012-12-11 10:44:28 -080013GDB="n"
jeffhao5d1ac922011-09-29 17:41:15 -070014DEBUG="n"
jeffhao0dff3f42012-11-20 15:13:43 -080015INTERPRETER="n"
jeffhao5d1ac922011-09-29 17:41:15 -070016VERIFY="y"
17OPTIMIZE="y"
Elliott Hughes58bcc402012-02-14 14:10:10 -080018ZYGOTE=""
jeffhao5d1ac922011-09-29 17:41:15 -070019QUIET="n"
jeffhao5d1ac922011-09-29 17:41:15 -070020DEV_MODE="n"
Elliott Hughes7c046102011-10-19 18:16:03 -070021INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070022
23while true; do
24 if [ "x$1" = "x--quiet" ]; then
25 QUIET="y"
26 shift
Ian Rogers7769f502012-02-03 18:02:28 -080027 elif [ "x$1" = "x-O" ]; then
28 OATEXEC="oatexec"
Elliott Hughes7c046102011-10-19 18:16:03 -070029 shift
jeffhao5d1ac922011-09-29 17:41:15 -070030 elif [ "x$1" = "x--debug" ]; then
31 DEBUG="y"
32 shift
Ian Rogers4c1bf1a2012-12-11 10:44:28 -080033 elif [ "x$1" = "x--gdb" ]; then
34 GDB="y"
35 DEV_MODE="y"
36 shift
jeffhao5d1ac922011-09-29 17:41:15 -070037 elif [ "x$1" = "x--zygote" ]; then
Elliott Hughes58bcc402012-02-14 14:10:10 -080038 ZYGOTE="--zygote"
jeffhao5d1ac922011-09-29 17:41:15 -070039 msg "Spawning from zygote"
40 shift
41 elif [ "x$1" = "x--dev" ]; then
42 DEV_MODE="y"
43 shift
jeffhao0dff3f42012-11-20 15:13:43 -080044 elif [ "x$1" = "x--interpreter" ]; then
45 INTERPRETER="y"
46 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070047 elif [ "x$1" = "x--invoke-with" ]; then
48 shift
49 INVOKE_WITH="$1"
50 shift
jeffhao5d1ac922011-09-29 17:41:15 -070051 elif [ "x$1" = "x--no-verify" ]; then
52 VERIFY="n"
53 shift
54 elif [ "x$1" = "x--no-optimize" ]; then
55 OPTIMIZE="n"
56 shift
jeffhao5d1ac922011-09-29 17:41:15 -070057 elif [ "x$1" = "x--" ]; then
58 shift
59 break
60 elif expr "x$1" : "x--" >/dev/null 2>&1; then
Elliott Hughes7c046102011-10-19 18:16:03 -070061 echo "unknown $0 option: $1" 1>&2
jeffhao5d1ac922011-09-29 17:41:15 -070062 exit 1
63 else
64 break
65 fi
66done
67
Elliott Hughes58bcc402012-02-14 14:10:10 -080068if [ "$ZYGOTE" = "" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -070069 if [ "$OPTIMIZE" = "y" ]; then
70 if [ "$VERIFY" = "y" ]; then
71 DEX_OPTIMIZE="-Xdexopt:verified"
72 else
73 DEX_OPTIMIZE="-Xdexopt:all"
74 fi
75 msg "Performing optimizations"
76 else
77 DEX_OPTIMIZE="-Xdexopt:none"
78 msg "Skipping optimizations"
79 fi
80
81 if [ "$VERIFY" = "y" ]; then
82 DEX_VERIFY=""
83 msg "Performing verification"
84 else
85 DEX_VERIFY="-Xverify:none"
86 msg "Skipping verification"
87 fi
88fi
89
90msg "------------------------------"
91
92if [ "$QUIET" = "n" ]; then
Brian Carlstrom4ec9b1f2012-06-17 22:27:43 -070093 adb shell rm -r $DEX_LOCATION
Brian Carlstrom105215d2012-06-14 12:50:44 -070094 adb shell mkdir -p $DEX_LOCATION
95 adb push $TEST_NAME.jar $DEX_LOCATION
96 adb push $TEST_NAME-ex.jar $DEX_LOCATION
jeffhao5d1ac922011-09-29 17:41:15 -070097else
Brian Carlstrom4ec9b1f2012-06-17 22:27:43 -070098 adb shell rm -r $DEX_LOCATION >/dev/null 2>&1
Brian Carlstrom105215d2012-06-14 12:50:44 -070099 adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1
100 adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1
101 adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700102fi
103
104if [ "$DEBUG" = "y" ]; then
Elliott Hughes72395bf2012-04-24 13:45:26 -0700105 # Use this instead for ddms and connect by running 'ddms':
106 # DEBUG_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
107 # TODO: add a separate --ddms option?
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700108
Elliott Hughes72395bf2012-04-24 13:45:26 -0700109 PORT=12345
110 msg "Waiting for jdb to connect:"
111 msg " adb forward tcp:$PORT tcp:$PORT"
112 msg " jdb -attach localhost:$PORT"
113 DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
jeffhao5d1ac922011-09-29 17:41:15 -0700114fi
115
Ian Rogers4c1bf1a2012-12-11 10:44:28 -0800116if [ "$GDB" = "y" ]; then
117 gdb="gdbserver :5039"
118 gdbargs="--args $exe"
119fi
120
jeffhao0dff3f42012-11-20 15:13:43 -0800121if [ "$INTERPRETER" = "y" ]; then
122 INT_OPTS="-Xint"
123fi
124
Mathieu Chartierdbe6f462012-09-25 16:54:50 -0700125JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
Elliott Hughes72395bf2012-04-24 13:45:26 -0700126
Brian Carlstrom105215d2012-06-14 12:50:44 -0700127cmdline="cd $DEX_LOCATION && mkdir art-cache && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \
Ian Rogers4c1bf1a2012-12-11 10:44:28 -0800128 $INVOKE_WITH $gdb $OATEXEC $gdbargs $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 -0800129if [ "$DEV_MODE" = "y" ]; then
130 echo $cmdline "$@"
jeffhao5d1ac922011-09-29 17:41:15 -0700131fi
Elliott Hughes58bcc402012-02-14 14:10:10 -0800132
133adb shell $cmdline "$@"