From 5fd18ba0902df62c4e1237712f03c44b8109ce8a Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 3 Oct 2014 12:08:38 +0100 Subject: [PATCH] Merge push-and-run-{prebuilt}-test-jar files. Can't find a reason why those two files forked... Change-Id: I5ef3dd76aa3b2d843c8b4b57365edec3bf2c3f3b --- test/etc/push-and-run-prebuilt-test-jar | 230 -------------------------------- test/etc/push-and-run-test-jar | 105 ++++++++++++--- test/run-test | 9 +- 3 files changed, 87 insertions(+), 257 deletions(-) delete mode 100755 test/etc/push-and-run-prebuilt-test-jar diff --git a/test/etc/push-and-run-prebuilt-test-jar b/test/etc/push-and-run-prebuilt-test-jar deleted file mode 100755 index 91b8a0f80..000000000 --- a/test/etc/push-and-run-prebuilt-test-jar +++ /dev/null @@ -1,230 +0,0 @@ -#!/bin/sh -# -# Run the code in test.jar on the device. The jar should contain a top-level -# class named Main to run. - -msg() { - if [ "$QUIET" = "n" ]; then - echo "$@" - fi -} - -ARCHITECTURES_32="(arm|x86|mips|none)" -ARCHITECTURES_64="(arm64|x86_64|none)" -ARCHITECTURES_PATTERN="${ARCHITECTURES_32}" -RELOCATE="y" -GDB="n" -DEBUGGER="n" -INTERPRETER="n" -VERIFY="y" -OPTIMIZE="y" -ZYGOTE="" -QUIET="n" -DEV_MODE="n" -INVOKE_WITH="" -FLAGS="" -TARGET_SUFFIX="32" -GDB_TARGET_SUFFIX="" -COMPILE_FLAGS="" -FALSE_BIN="/system/bin/false" -PATCHOAT="" -DEX2OAT="" -HAVE_IMAGE="y" - -while true; do - if [ "x$1" = "x--quiet" ]; then - QUIET="y" - shift - elif [ "x$1" = "x--lib" ]; then - shift - if [ "x$1" = "x" ]; then - echo "$0 missing argument to --lib" 1>&2 - exit 1 - fi - LIB="$1" - shift - elif [ "x$1" = "x-Xcompiler-option" ]; then - shift - option="$1" - FLAGS="${FLAGS} -Xcompiler-option $option" - COMPILE_FLAGS="${COMPILE_FLAGS} $option" - shift - elif [ "x$1" = "x--runtime-option" ]; then - shift - option="$1" - FLAGS="${FLAGS} $option" - shift - elif [ "x$1" = "x--boot" ]; then - shift - BOOT_OPT="$1" - BUILD_BOOT_OPT="--boot-image=${1#-Ximage:}" - shift - elif [ "x$1" = "x--no-dex2oat" ]; then - DEX2OAT="-Xcompiler:${FALSE_BIN}" - shift - elif [ "x$1" = "x--no-patchoat" ]; then - PATCHOAT="-Xpatchoat:${FALSE_BIN}" - shift - elif [ "x$1" = "x--relocate" ]; then - RELOCATE="y" - shift - elif [ "x$1" = "x--no-relocate" ]; then - RELOCATE="n" - shift - elif [ "x$1" = "x--no-image" ]; then - HAVE_IMAGE="n" - shift - elif [ "x$1" = "x--debug" ]; then - DEBUGGER="y" - shift - elif [ "x$1" = "x--gdb" ]; then - GDB="y" - DEV_MODE="y" - shift - elif [ "x$1" = "x--zygote" ]; then - ZYGOTE="--zygote" - msg "Spawning from zygote" - shift - elif [ "x$1" = "x--dev" ]; then - DEV_MODE="y" - shift - elif [ "x$1" = "x--interpreter" ]; then - INTERPRETER="y" - shift - elif [ "x$1" = "x--invoke-with" ]; then - shift - if [ "x$1" = "x" ]; then - echo "$0 missing argument to --invoke-with" 1>&2 - exit 1 - fi - if [ "x$INVOKE_WITH" = "x" ]; then - INVOKE_WITH="$1" - else - INVOKE_WITH="$INVOKE_WITH $1" - fi - shift - elif [ "x$1" = "x--no-verify" ]; then - VERIFY="n" - shift - elif [ "x$1" = "x--no-optimize" ]; then - OPTIMIZE="n" - shift - elif [ "x$1" = "x--" ]; then - shift - break - elif [ "x$1" = "x--64" ]; then - TARGET_SUFFIX="64" - GDB_TARGET_SUFFIX="64" - ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" - shift - elif expr "x$1" : "x--" >/dev/null 2>&1; then - echo "unknown $0 option: $1" 1>&2 - exit 1 - else - break - fi -done - -if [ "$ZYGOTE" = "" ]; then - if [ "$OPTIMIZE" = "y" ]; then - if [ "$VERIFY" = "y" ]; then - DEX_OPTIMIZE="-Xdexopt:verified" - else - DEX_OPTIMIZE="-Xdexopt:all" - fi - msg "Performing optimizations" - else - DEX_OPTIMIZE="-Xdexopt:none" - msg "Skipping optimizations" - fi - - if [ "$VERIFY" = "y" ]; then - DEX_VERIFY="" - msg "Performing verification" - else - DEX_VERIFY="-Xverify:none" - msg "Skipping verification" - fi -fi - -msg "------------------------------" - -if [ "$HAVE_IMAGE" = "n" ]; then - BOOT_OPT="-Ximage:/system/non-existant/core.art" -fi - -ARCH=$(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}") -if [ x"$ARCH" = "x" ]; then - echo "Unable to determine architecture" - exit 1 -fi - -if [ "$QUIET" = "n" ]; then - adb shell rm -r $DEX_LOCATION - adb shell mkdir -p $DEX_LOCATION - adb push $TEST_NAME.jar $DEX_LOCATION - adb push $TEST_NAME-ex.jar $DEX_LOCATION -else - adb shell rm -r $DEX_LOCATION >/dev/null 2>&1 - adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1 - adb push $TEST_NAME.jar $DEX_LOCATION >/dev/null 2>&1 - adb push $TEST_NAME-ex.jar $DEX_LOCATION >/dev/null 2>&1 -fi - -if [ "$DEBUGGER" = "y" ]; then - # Use this instead for ddms and connect by running 'ddms': - # DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_android_adb,server=y,suspend=y" - # TODO: add a separate --ddms option? - - PORT=12345 - msg "Waiting for jdb to connect:" - msg " adb forward tcp:$PORT tcp:$PORT" - msg " jdb -attach localhost:$PORT" - DEBUGGER_OPTS="-agentlib:jdwp=transport=dt_socket,address=$PORT,server=y,suspend=y" -fi - -if [ "$GDB" = "y" ]; then - gdb="gdbserver$GDB_TARGET_SUFFIX :5039" - gdbargs="$exe" -fi - -if [ "$INTERPRETER" = "y" ]; then - INT_OPTS="-Xint" - COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only" -fi - -JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" - -if [ "$RELOCATE" = "y" ]; then - RELOCATE_OPT="-Xrelocate" - BUILD_RELOCATE_OPT="--runtime-arg -Xnorelocate" - COMPILE_FLAGS="${COMPILE_FLAGS} --include-patch-information" - FLAGS="${FLAGS} -Xcompiler-option --include-patch-information" -else - RELOCATE_OPT="-Xnorelocate" - BUILD_RELOCATE_OPT="--runtime-arg -Xnorelocate" -fi - -# This is due to the fact this cmdline can get longer than the longest allowed -# adb command and there is no way to get the exit status from a adb shell -# command. -cmdline="cd $DEX_LOCATION && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \ - mkdir -p $DEX_LOCATION/dalvik-cache/$ARCH/ && \ - $INVOKE_WITH /system/bin/dex2oatd $COMPILE_FLAGS $BUILD_BOOT_OPT $BUILD_RELOCATE_OPT --runtime-arg -classpath --runtime-arg $DEX_LOCATION/$TEST_NAME.jar --dex-file=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$DEX_LOCATION/dalvik-cache/$ARCH/$(echo $DEX_LOCATION/$TEST_NAME.jar/classes.dex | cut -d/ -f 2- | sed "s:/:@:g") --instruction-set=$ARCH && \ - $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $PATCHOAT $DEX2OAT $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main $@" -cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") -echo "$cmdline" > $cmdfile - -if [ "$DEV_MODE" = "y" ]; then - echo $cmdline -fi - -if [ "$QUIET" = "n" ]; then - adb push $cmdfile $DEX_LOCATION/cmdline.sh -else - adb push $cmdfile $DEX_LOCATION/cmdline.sh > /dev/null 2>&1 -fi - -adb shell sh $DEX_LOCATION/cmdline.sh - -rm -f $cmdfile diff --git a/test/etc/push-and-run-test-jar b/test/etc/push-and-run-test-jar index e398b5d58..d3ad71f32 100755 --- a/test/etc/push-and-run-test-jar +++ b/test/etc/push-and-run-test-jar @@ -9,6 +9,9 @@ msg() { fi } +ARCHITECTURES_32="(arm|x86|mips|none)" +ARCHITECTURES_64="(arm64|x86_64|none)" +ARCHITECTURES_PATTERN="${ARCHITECTURES_32}" RELOCATE="y" GDB="n" DEBUGGER="n" @@ -22,10 +25,12 @@ INVOKE_WITH="" FLAGS="" TARGET_SUFFIX="32" GDB_TARGET_SUFFIX="" +COMPILE_FLAGS="" FALSE_BIN="/system/bin/false" PATCHOAT="" DEX2OAT="" HAVE_IMAGE="y" +PREBUILD="y" while true; do if [ "x$1" = "x--quiet" ]; then @@ -43,9 +48,17 @@ while true; do shift option="$1" FLAGS="${FLAGS} -Xcompiler-option $option" + COMPILE_FLAGS="${COMPILE_FLAGS} $option" shift - elif [ "x$1" = "x--no-image" ]; then - HAVE_IMAGE="n" + elif [ "x$1" = "x--runtime-option" ]; then + shift + option="$1" + FLAGS="${FLAGS} $option" + shift + elif [ "x$1" = "x--boot" ]; then + shift + BOOT_OPT="$1" + BUILD_BOOT_OPT="--boot-image=${1#-Ximage:}" shift elif [ "x$1" = "x--no-dex2oat" ]; then DEX2OAT="-Xcompiler:${FALSE_BIN}" @@ -53,14 +66,20 @@ while true; do elif [ "x$1" = "x--no-patchoat" ]; then PATCHOAT="-Xpatchoat:${FALSE_BIN}" shift - elif [ "x$1" = "x--runtime-option" ]; then + elif [ "x$1" = "x--relocate" ]; then + RELOCATE="y" shift - option="$1" - FLAGS="${FLAGS} $option" + elif [ "x$1" = "x--no-relocate" ]; then + RELOCATE="n" shift - elif [ "x$1" = "x--boot" ]; then + elif [ "x$1" = "x--prebuild" ]; then + PREBUILD="y" shift - BOOT_OPT="$1" + elif [ "x$1" = "x--no-prebuild" ]; then + PREBUILD="n" + shift + elif [ "x$1" = "x--no-image" ]; then + HAVE_IMAGE="n" shift elif [ "x$1" = "x--debug" ]; then DEBUGGER="y" @@ -76,12 +95,6 @@ while true; do elif [ "x$1" = "x--dev" ]; then DEV_MODE="y" shift - elif [ "x$1" = "x--relocate" ]; then - RELOCATE="y" - shift - elif [ "x$1" = "x--no-relocate" ]; then - RELOCATE="n" - shift elif [ "x$1" = "x--interpreter" ]; then INTERPRETER="y" shift @@ -109,6 +122,7 @@ while true; do elif [ "x$1" = "x--64" ]; then TARGET_SUFFIX="64" GDB_TARGET_SUFFIX="64" + ARCHITECTURES_PATTERN="${ARCHITECTURES_64}" shift elif expr "x$1" : "x--" >/dev/null 2>&1; then echo "unknown $0 option: $1" 1>&2 @@ -146,6 +160,12 @@ if [ "$HAVE_IMAGE" = "n" ]; then BOOT_OPT="-Ximage:/system/non-existant/core.art" fi +ARCH=$(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}") +if [ x"$ARCH" = "x" ]; then + echo "Unable to determine architecture" + exit 1 +fi + if [ "$QUIET" = "n" ]; then adb shell rm -r $DEX_LOCATION adb shell mkdir -p $DEX_LOCATION @@ -177,21 +197,66 @@ fi if [ "$INTERPRETER" = "y" ]; then INT_OPTS="-Xint" + COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only" fi JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" if [ "$RELOCATE" = "y" ]; then - RELOCATE_OPT="-Xrelocate" - FLAGS="${FLAGS} -Xcompiler-option --include-patch-information" + RELOCATE_OPT="-Xrelocate" + BUILD_RELOCATE_OPT="--runtime-arg -Xnorelocate" + COMPILE_FLAGS="${COMPILE_FLAGS} --include-patch-information" + FLAGS="${FLAGS} -Xcompiler-option --include-patch-information" else - RELOCATE_OPT="-Xnorelocate" + RELOCATE_OPT="-Xnorelocate" + BUILD_RELOCATE_OPT="--runtime-arg -Xnorelocate" fi -cmdline="cd $DEX_LOCATION && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \ - $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $PATCHOAT $DEX2OAT $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main" +# Create a script with the command. The command can get longer than the longest +# allowed adb command and there is no way to get the exit status from a adb shell +# command. +cmdline="cd $DEX_LOCATION && \ + export ANDROID_DATA=$DEX_LOCATION && \ + export DEX_LOCATION=$DEX_LOCATION && " +if [ "$PREBUILD" = "y" ]; then + cmdline+="mkdir -p $DEX_LOCATION/dalvik-cache/$ARCH/ && \ + $INVOKE_WITH /system/bin/dex2oatd \ + $COMPILE_FLAGS \ + $BUILD_BOOT_OPT \ + $BUILD_RELOCATE_OPT \ + --runtime-arg -classpath --runtime-arg $DEX_LOCATION/$TEST_NAME.jar \ + --dex-file=$DEX_LOCATION/$TEST_NAME.jar \ + --oat-file=$DEX_LOCATION/dalvik-cache/$ARCH/$(echo $DEX_LOCATION/$TEST_NAME.jar/classes.dex | cut -d/ -f 2- | sed "s:/:@:g") \ + --instruction-set=$ARCH && " +fi + +cmdline+="$INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX \ + $FLAGS \ + $gdbargs \ + -XXlib:$LIB \ + $PATCHOAT \ + $DEX2OAT \ + $ZYGOTE \ + $JNI_OPTS \ + $RELOCATE_OPT \ + $INT_OPTS \ + $DEBUGGER_OPTS \ + $BOOT_OPT \ + -cp $DEX_LOCATION/$TEST_NAME.jar Main" + +cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") +echo "$cmdline" > $cmdfile + if [ "$DEV_MODE" = "y" ]; then - echo $cmdline "$@" + echo $cmdline fi -adb shell $cmdline "$@" +if [ "$QUIET" = "n" ]; then + adb push $cmdfile $DEX_LOCATION/cmdline.sh +else + adb push $cmdfile $DEX_LOCATION/cmdline.sh > /dev/null 2>&1 +fi + +adb shell sh $DEX_LOCATION/cmdline.sh + +rm -f $cmdfile diff --git a/test/run-test b/test/run-test index b140fbf81..4f1cbab24 100755 --- a/test/run-test +++ b/test/run-test @@ -118,9 +118,11 @@ while true; do relocate="no" shift elif [ "x$1" = "x--prebuild" ]; then + run_args="${run_args} --prebuild" prebuild_mode="yes" shift; elif [ "x$1" = "x--no-prebuild" ]; then + run_args="${run_args} --no-prebuild" prebuild_mode="no" shift; elif [ "x$1" = "x--gcverify" ]; then @@ -263,13 +265,6 @@ if [ "$target_mode" = "no" ]; then fi else RUN="${progdir}/etc/host-run-test-jar" - if [ "$prebuild_mode" = "yes" ]; then - run_args="${run_args} --prebuild" - fi - fi -else - if [ "$prebuild_mode" = "yes" ]; then - RUN="${progdir}/etc/push-and-run-prebuilt-test-jar" fi fi -- 2.11.0