host-run-test-jar revision a59dd80f9f48cb750d329d4d4af2d99d72b484d1
1#!/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. 5 6msg() { 7 if [ "$QUIET" = "n" ]; then 8 echo "$@" 9 fi 10} 11 12DEBUGGER="n" 13PREBUILD="n" 14GDB="n" 15ISA="x86" 16INTERPRETER="n" 17VERIFY="y" 18RELOCATE="y" 19OPTIMIZE="y" 20INVOKE_WITH="" 21DEV_MODE="n" 22QUIET="n" 23FLAGS="" 24COMPILER_FLAGS="" 25BUILD_BOOT_OPT="" 26exe="${ANDROID_HOST_OUT}/bin/dalvikvm32" 27 28while true; do 29 if [ "x$1" = "x--quiet" ]; then 30 QUIET="y" 31 shift 32 elif [ "x$1" = "x--prebuild" ]; then 33 PREBUILD="y" 34 shift 35 elif [ "x$1" = "x--lib" ]; then 36 shift 37 if [ "x$1" = "x" ]; then 38 echo "$0 missing argument to --lib" 1>&2 39 exit 1 40 fi 41 LIB="$1" 42 if [ `uname` = "Darwin" ]; then 43 LIB=${LIB/%so/dylib} 44 fi 45 shift 46 elif [ "x$1" = "x--boot" ]; then 47 shift 48 option="$1" 49 BOOT_OPT="$option" 50 BUILD_BOOT_OPT="--boot-image=${option#-Ximage:}" 51 shift 52 elif [ "x$1" = "x--debug" ]; then 53 DEBUGGER="y" 54 shift 55 elif [ "x$1" = "x--gdb" ]; then 56 GDB="y" 57 DEV_MODE="y" 58 shift 59 elif [ "x$1" = "x--invoke-with" ]; then 60 shift 61 if [ "x$1" = "x" ]; then 62 echo "$0 missing argument to --invoke-with" 1>&2 63 exit 1 64 fi 65 if [ "x$INVOKE_WITH" = "x" ]; then 66 INVOKE_WITH="$1" 67 else 68 INVOKE_WITH="$INVOKE_WITH $1" 69 fi 70 shift 71 elif [ "x$1" = "x--dev" ]; then 72 DEV_MODE="y" 73 shift 74 elif [ "x$1" = "x--interpreter" ]; then 75 INTERPRETER="y" 76 shift 77 elif [ "x$1" = "x--64" ]; then 78 ISA="x64" 79 exe="${ANDROID_HOST_OUT}/bin/dalvikvm64" 80 shift 81 elif [ "x$1" = "x--no-verify" ]; then 82 VERIFY="n" 83 shift 84 elif [ "x$1" = "x--no-optimize" ]; then 85 OPTIMIZE="n" 86 shift 87 elif [ "x$1" = "x--no-relocate" ]; then 88 RELOCATE="n" 89 shift 90 elif [ "x$1" = "x--relocate" ]; then 91 RELOCATE="y" 92 shift 93 elif [ "x$1" = "x-Xcompiler-option" ]; then 94 shift 95 option="$1" 96 FLAGS="${FLAGS} -Xcompiler-option $option" 97 COMPILER_FLAGS="${COMPILER_FLAGS} $option" 98 shift 99 elif [ "x$1" = "x--runtime-option" ]; then 100 shift 101 option="$1" 102 FLAGS="${FLAGS} $option" 103 COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg $option" 104 shift 105 elif [ "x$1" = "x--" ]; then 106 shift 107 break 108 elif expr "x$1" : "x--" >/dev/null 2>&1; then 109 echo "unknown $0 option: $1" 1>&2 110 exit 1 111 else 112 break 113 fi 114done 115 116msg "------------------------------" 117 118export ANDROID_PRINTF_LOG=brief 119if [ "$DEV_MODE" = "y" ]; then 120 export ANDROID_LOG_TAGS='*:d' 121else 122 export ANDROID_LOG_TAGS='*:s' 123fi 124export ANDROID_DATA="$DEX_LOCATION" 125export ANDROID_ROOT="${ANDROID_HOST_OUT}" 126export LD_LIBRARY_PATH="${ANDROID_ROOT}/lib" 127export DYLD_LIBRARY_PATH="${ANDROID_ROOT}/lib" 128 129if [ "$DEBUGGER" = "y" ]; then 130 PORT=8000 131 msg "Waiting for jdb to connect:" 132 msg " jdb -attach localhost:$PORT" 133 DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" 134fi 135 136if [ "$GDB" = "y" ]; then 137 if [ `uname` = "Darwin" ]; then 138 gdb=lldb 139 gdbargs="-- $exe" 140 exe= 141 else 142 gdb=gdb 143 gdbargs="--args $exe" 144 # Enable for Emacs "M-x gdb" support. TODO: allow extra gdb arguments on command line. 145 # gdbargs="--annotate=3 $gdbargs" 146 fi 147fi 148 149if [ "$INTERPRETER" = "y" ]; then 150 INT_OPTS="-Xint" 151 COMPILER_FLAGS="${COMPILER_FLAGS} --compiler-filter=interpret-only" 152fi 153 154if [ "$RELOCATE" = "y" ]; then 155 FLAGS="${FLAGS} -Xrelocate" 156 COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -Xnorelocate --include-patch-information" 157 # Run test sets a fairly draconian ulimit that we will likely blow right over 158 # since we are relocating. Get the total size of the /system/framework directory 159 # in 512 byte blocks and set it as the ulimit. This should be more than enough 160 # room. 161 ulimit -S $(du -c -B512 ${ANDROID_ROOT}/framework | tail -1 | cut -f1) || exit 1 162else 163 FLAGS="${FLAGS} -Xnorelocate" 164 COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -Xnorelocate --no-include-patch-information" 165fi 166 167mkdir_cmd="mkdir -p ${DEX_LOCATION}/dalvik-cache/$ISA" 168if [ "$PREBUILD" = "y" ]; then 169 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")" 170else 171 prebuild_cmd="true" 172fi 173 174JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" 175cmdline="$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main" 176if [ "$DEV_MODE" = "y" ]; then 177 if [ "$PREBUILD" = "y" ]; then 178 echo "$mkdir_cmd && $prebuild_cmd && $cmdline" 179 elif [ "$RELOCATE" = "y" ]; then 180 echo "$mkdir_cmd && $cmdline" 181 else 182 echo $cmdline 183 fi 184fi 185 186cd $ANDROID_BUILD_TOP 187$mkdir_cmd && $prebuild_cmd && $cmdline "$@" 188