blob: c892309456f76a9c46ad484c853a26458f17d4a5 [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)
11# --no-verify -- turn off verification (on by default)
12# --no-optimize -- turn off optimization (on by default)
13# --no-precise -- turn off precise GC (on by default)
Ian Rogers7769f502012-02-03 18:02:28 -080014# -O -- run non-debug code
jeffhao5d1ac922011-09-29 17:41:15 -070015
16msg() {
17 if [ "$QUIET" = "n" ]; then
18 echo "$@"
19 fi
20}
21
Ian Rogers7769f502012-02-03 18:02:28 -080022OATEXEC="oatexecd"
jeffhao5d1ac922011-09-29 17:41:15 -070023DEBUG="n"
24VERIFY="y"
25OPTIMIZE="y"
Elliott Hughes58bcc402012-02-14 14:10:10 -080026ZYGOTE=""
jeffhao5d1ac922011-09-29 17:41:15 -070027QUIET="n"
jeffhao5d1ac922011-09-29 17:41:15 -070028DEV_MODE="n"
Elliott Hughes7c046102011-10-19 18:16:03 -070029INVOKE_WITH=""
jeffhao5d1ac922011-09-29 17:41:15 -070030
31while true; do
32 if [ "x$1" = "x--quiet" ]; then
33 QUIET="y"
34 shift
Ian Rogers7769f502012-02-03 18:02:28 -080035 elif [ "x$1" = "x-O" ]; then
36 OATEXEC="oatexec"
Elliott Hughes7c046102011-10-19 18:16:03 -070037 shift
jeffhao5d1ac922011-09-29 17:41:15 -070038 elif [ "x$1" = "x--debug" ]; then
39 DEBUG="y"
40 shift
41 elif [ "x$1" = "x--zygote" ]; then
Elliott Hughes58bcc402012-02-14 14:10:10 -080042 ZYGOTE="--zygote"
jeffhao5d1ac922011-09-29 17:41:15 -070043 msg "Spawning from zygote"
44 shift
45 elif [ "x$1" = "x--dev" ]; then
46 DEV_MODE="y"
47 shift
Elliott Hughes7c046102011-10-19 18:16:03 -070048 elif [ "x$1" = "x--invoke-with" ]; then
49 shift
50 INVOKE_WITH="$1"
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
Elliott Hughes58bcc402012-02-14 14:10:10 -080069if [ "$ZYGOTE" = "" ]; then
jeffhao5d1ac922011-09-29 17:41:15 -070070 if [ "$OPTIMIZE" = "y" ]; then
71 if [ "$VERIFY" = "y" ]; then
72 DEX_OPTIMIZE="-Xdexopt:verified"
73 else
74 DEX_OPTIMIZE="-Xdexopt:all"
75 fi
76 msg "Performing optimizations"
77 else
78 DEX_OPTIMIZE="-Xdexopt:none"
79 msg "Skipping optimizations"
80 fi
81
82 if [ "$VERIFY" = "y" ]; then
83 DEX_VERIFY=""
84 msg "Performing verification"
85 else
86 DEX_VERIFY="-Xverify:none"
87 msg "Skipping verification"
88 fi
89fi
90
91msg "------------------------------"
92
93if [ "$QUIET" = "n" ]; then
Brian Carlstrom78325a42012-03-06 22:56:41 -080094 adb shell mkdir /data/run-test
Brian Carlstrom904667a2012-03-10 23:43:07 -080095 adb push $TEST_NAME.jar /data/run-test
96 adb push $TEST_NAME.jar.oat /data/run-test
97 adb push $TEST_NAME-ex.jar /data/run-test
98 adb push $TEST_NAME-ex.jar.oat /data/run-test
jeffhao5d1ac922011-09-29 17:41:15 -070099else
Brian Carlstrom78325a42012-03-06 22:56:41 -0800100 adb shell mkdir /data/run-test >/dev/null 2>&1
Brian Carlstrom904667a2012-03-10 23:43:07 -0800101 adb push $TEST_NAME.jar /data/run-test >/dev/null 2>&1
102 adb push $TEST_NAME.jar.oat /data/run-test >/dev/null 2>&1
103 adb push $TEST_NAME-ex.jar /data/run-test >/dev/null 2>&1
104 adb push $TEST_NAME-ex.jar.oat /data/run-test >/dev/null 2>&1
jeffhao5d1ac922011-09-29 17:41:15 -0700105fi
106
107if [ "$DEBUG" = "y" ]; then
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700108 # This is for ddms:
Elliott Hughesa2155262011-11-16 16:26:58 -0800109 #DEX_DEBUG="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y"
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700110 # Connect by running 'ddms'.
111
112 # This is for jdb:
Elliott Hughesa2155262011-11-16 16:26:58 -0800113 DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,address=12345,server=y,suspend=y"
Elliott Hughesd1cc8362011-10-24 16:58:50 -0700114 # Connect thus:
115 # adb forward tcp:12345 tcp:12345
116 # jdb -attach localhost:12345
jeffhao5d1ac922011-09-29 17:41:15 -0700117fi
118
TDYa1276ce558b2012-04-11 11:17:55 -0700119cmdline="cd /data; export DEX_LOCATION=$DEX_LOCATION; $INVOKE_WITH $OATEXEC $DEX_DEBUG $ZYGOTE -Xjnigreflimit:256 \
Elliott Hughes58bcc402012-02-14 14:10:10 -0800120 -Ximage:/data/art-test/core.art \
Brian Carlstrom78325a42012-03-06 22:56:41 -0800121 -cp /data/run-test/$TEST_NAME.jar \
Elliott Hughes58bcc402012-02-14 14:10:10 -0800122 Main"
123if [ "$DEV_MODE" = "y" ]; then
124 echo $cmdline "$@"
jeffhao5d1ac922011-09-29 17:41:15 -0700125fi
Elliott Hughes58bcc402012-02-14 14:10:10 -0800126
127adb shell $cmdline "$@"