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.
7 if [ "$QUIET" = "n" ]; then
26 exe="${ANDROID_HOST_OUT}/bin/dalvikvm32"
30 if [ "x$1" = "x--quiet" ]; then
33 elif [ "x$1" = "x--prebuild" ]; then
36 elif [ "x$1" = "x--lib" ]; then
38 if [ "x$1" = "x" ]; then
39 echo "$0 missing argument to --lib" 1>&2
43 if [ `uname` = "Darwin" ]; then
47 elif [ "x$1" = "x--boot" ]; then
51 BUILD_BOOT_OPT="--boot-image=${option#-Ximage:}"
53 elif [ "x$1" = "x--debug" ]; then
56 elif [ "x$1" = "x--gdb" ]; then
60 elif [ "x$1" = "x--invoke-with" ]; then
62 if [ "x$1" = "x" ]; then
63 echo "$0 missing argument to --invoke-with" 1>&2
66 if [ "x$INVOKE_WITH" = "x" ]; then
69 INVOKE_WITH="$INVOKE_WITH $1"
72 elif [ "x$1" = "x--dev" ]; then
75 elif [ "x$1" = "x--interpreter" ]; then
78 elif [ "x$1" = "x--64" ]; then
80 exe="${ANDROID_HOST_OUT}/bin/dalvikvm64"
82 elif [ "x$1" = "x--no-verify" ]; then
85 elif [ "x$1" = "x--no-optimize" ]; then
88 elif [ "x$1" = "x--no-relocate" ]; then
91 elif [ "x$1" = "x--relocate" ]; then
94 elif [ "x$1" = "x-Xcompiler-option" ]; then
97 FLAGS="${FLAGS} -Xcompiler-option $option"
98 COMPILER_FLAGS="${COMPILER_FLAGS} $option"
100 elif [ "x$1" = "x--runtime-option" ]; then
103 FLAGS="${FLAGS} $option"
105 elif [ "x$1" = "x--" ]; then
108 elif expr "x$1" : "x--" >/dev/null 2>&1; then
109 echo "unknown $0 option: $1" 1>&2
116 if [ "x$1" = "x" ] ; then
122 msg "------------------------------"
124 export ANDROID_PRINTF_LOG=brief
125 if [ "$DEV_MODE" = "y" ]; then
126 export ANDROID_LOG_TAGS='*:d'
128 export ANDROID_LOG_TAGS='*:s'
130 export ANDROID_DATA="$DEX_LOCATION"
131 export ANDROID_ROOT="${ANDROID_HOST_OUT}"
132 export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
133 export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib"
135 if [ "$DEBUGGER" = "y" ]; then
137 msg "Waiting for jdb to connect:"
138 msg " jdb -attach localhost:$PORT"
139 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y"
142 if [ "$GDB" = "y" ]; then
143 if [ `uname` = "Darwin" ]; then
149 gdbargs="--args $exe"
150 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line.
151 # gdbargs="--annotate=3 $gdbargs"
155 if [ "$INTERPRETER" = "y" ]; then
157 COMPILER_FLAGS="${COMPILER_FLAGS} --compiler-filter=interpret-only"
160 if [ "$RELOCATE" = "y" ]; then
161 FLAGS="${FLAGS} -Xrelocate"
162 COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -Xnorelocate --include-patch-information"
163 # Run test sets a fairly draconian ulimit that we will likely blow right over
164 # since we are relocating. Get the total size of the /system/framework directory
165 # in 512 byte blocks and set it as the ulimit. This should be more than enough
167 ulimit -S $(du -c -B512 ${ANDROID_ROOT}/framework | tail -1 | cut -f1) || exit 1
169 FLAGS="${FLAGS} -Xnorelocate"
170 COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -Xnorelocate --no-include-patch-information"
173 mkdir_cmd="mkdir -p ${DEX_LOCATION}/dalvik-cache/$ISA"
174 if [ "$PREBUILD" = "y" ]; then
175 prebuild_cmd="${ANDROID_HOST_OUT}/bin/dex2oatd $COMPILER_FLAGS --instruction-set=$ISA $BUILD_BOOT_OPT --dex-file=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$DEX_LOCATION/dalvik-cache/$ISA/$(echo $DEX_LOCATION/$TEST_NAME.jar/classes.dex | cut -d/ -f 2- | sed "s:/:@:g")"
180 JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni"
181 cmdline="$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar $main"
182 if [ "$DEV_MODE" = "y" ]; then
183 if [ "$PREBUILD" = "y" ]; then
184 echo "$mkdir_cmd && $prebuild_cmd && $cmdline"
185 elif [ "$RELOCATE" = "y" ]; then
186 echo "$mkdir_cmd && $cmdline"
192 cd $ANDROID_BUILD_TOP
193 $mkdir_cmd && $prebuild_cmd && LD_PRELOAD=libsigchain.so $cmdline "$@"