Have tools/run-{libcore,jdwp}-tests.sh honor ART_TEST_CHROOT.
Also remove explicit handling of `--chroot` option from these
scripts.
Test: ART_TEST_CHROOT=/data/local/art-test-chroot tools/run-libcore-tests.sh --mode=device --variant=X64
Test: ART_TEST_CHROOT=/data/local/art-test-chroot tools/run-jdwp-tests.sh --mode=device --variant=X64
Bug: 34729697
Change-Id: Id583ea16b36c3eebc1f80868c06ed26174cb4533
diff --git a/tools/run-jdwp-tests.sh b/tools/run-jdwp-tests.sh
index eebc092..0796432 100755
--- a/tools/run-jdwp-tests.sh
+++ b/tools/run-jdwp-tests.sh
@@ -36,10 +36,9 @@
ANDROID_HOST_OUT=${OUT_DIR-$ANDROID_BUILD_TOP/out}/host/linux-x86
fi
-android_root="/system"
-if [ -n "$ART_TEST_ANDROID_ROOT" ]; then
- android_root="$ART_TEST_ANDROID_ROOT"
-fi
+# "Root" (actually "system") directory on device (in the case of
+# target testing).
+android_root=${ART_TEST_ANDROID_ROOT:-/system}
java_lib_location="${ANDROID_HOST_OUT}/../common/obj/JAVA_LIBRARIES"
make_target_name="apache-harmony-jdwp-tests-hostdex"
@@ -48,6 +47,7 @@
art="$android_root/bin/art"
art_debugee="sh $android_root/bin/art"
args=$@
+chroot_option=
debuggee_args="-Xcompiler-option --debuggable"
device_dir="--device-dir=/data/local/tmp"
# We use the art script on target to ensure the runner and the debuggee share the same
@@ -68,8 +68,6 @@
mode="target"
# Use JIT compiling by default.
use_jit=true
-# Don't use chroot by default.
-use_chroot=false
variant_cmdline_parameter="--variant=X32"
dump_command="/bin/true"
# Timeout of JDWP test in ms.
@@ -112,15 +110,6 @@
# We don't care about jit with the RI
use_jit=false
shift
- elif [[ "$1" == "--chroot" ]]; then
- use_chroot=true
- # Adjust settings for chroot environment.
- art="/system/bin/art"
- art_debugee="sh /system/bin/art"
- vm_command="--vm-command=$art"
- device_dir="--device-dir=/tmp"
- # Shift the "--chroot" flag and its argument.
- shift 2
elif [[ $1 == --test-timeout-ms ]]; then
# Remove the --test-timeout-ms from the arguments.
args=${args/$1}
@@ -202,10 +191,17 @@
fi
done
-if $use_chroot && [[ $mode == "host" ]]; then
- # Chroot-based testing is not supported on host.
- echo "Cannot use --chroot with --mode=host"
- exit 1
+if [[ $mode == "target" ]]; then
+ # Honor environment variable ART_TEST_CHROOT.
+ if [[ -n "$ART_TEST_CHROOT" ]]; then
+ # Set Vogar's `--chroot` option.
+ chroot_option="--chroot $ART_TEST_CHROOT"
+ # Adjust settings for chroot environment.
+ art="/system/bin/art"
+ art_debugee="sh /system/bin/art"
+ vm_command="--vm-command=$art"
+ device_dir="--device-dir=/tmp"
+ fi
fi
if [[ $has_gdb = "yes" ]]; then
@@ -341,6 +337,7 @@
$vm_args \
--verbose \
$args \
+ $chroot_option \
$device_dir \
$image_compiler_option \
--timeout 800 \
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index 3537c1b..aff009a 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -28,10 +28,9 @@
JAVA_LIBRARIES=${ANDROID_PRODUCT_OUT}/../../common/obj/JAVA_LIBRARIES
fi
-android_root="/system"
-if [ -n "$ART_TEST_ANDROID_ROOT" ]; then
- android_root="$ART_TEST_ANDROID_ROOT"
-fi
+# "Root" (actually "system") directory on device (in the case of
+# target testing).
+android_root=${ART_TEST_ANDROID_ROOT:-/system}
function classes_jar_path {
local var="$1"
@@ -106,8 +105,6 @@
# Don't use device mode by default.
device_mode=false
-# Don't use chroot by default.
-use_chroot=false
while true; do
if [[ "$1" == "--mode=device" ]]; then
@@ -135,10 +132,6 @@
elif [[ "$1" == "-Xgc:gcstress" ]]; then
gcstress=true
shift
- elif [[ "$1" == "--chroot" ]]; then
- use_chroot=true
- # Shift the "--chroot" flag and its argument.
- shift 2
elif [[ "$1" == "" ]]; then
break
else
@@ -147,20 +140,17 @@
done
if $device_mode; then
- if $use_chroot; then
+ # Honor environment variable ART_TEST_CHROOT.
+ if [[ -n "$ART_TEST_CHROOT" ]]; then
+ # Set Vogar's `--chroot` option.
+ vogar_args="$vogar_args --chroot $ART_TEST_CHROOT"
vogar_args="$vogar_args --device-dir=/tmp"
- vogar_args="$vogar_args --vm-command=/system/bin/art"
else
+ # When not using a chroot on device, set Vogar's work directory to
+ # /data/local/tmp.
vogar_args="$vogar_args --device-dir=/data/local/tmp"
- vogar_args="$vogar_args --vm-command=$android_root/bin/art"
fi
-else
- # Host mode.
- if $use_chroot; then
- # Chroot-based testing is not supported on host.
- echo "Cannot use --chroot with --mode=host"
- exit 1
- fi
+ vogar_args="$vogar_args --vm-command=$android_root/bin/art"
fi
# Increase the timeout, as vogar cannot set individual test