Support a chroot-based environment in ART Buildbot's target harness.
When ART_TEST_CHROOT is defined, instead of having the ART Buildbot
install ART into a local path (set with ART_TEST_ANDROID_ROOT) and
hijack the linker (using CUSTOM_TARGET_LINKER), prepare and use a
chroot environment (set with ART_TEST_CHROOT).
In this scenario, ART and its dependencies can be built and used
normally (in particular, when building from the master-art Android
manifest) and still be executed as a standalone runtime outside of
the device's /system path, for testing purposes.
Test: Have the ART Buildbot build and run ART on device with chroot.
Bug: 34729697
Bug: 68125496
Change-Id: I08f1acd0d2813584f703fedb84e69df954cbdbda
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index 26b5c0a..3537c1b 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -104,10 +104,14 @@
gcstress=false
debug=false
+# 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
- vogar_args="$vogar_args --device-dir=/data/local/tmp"
- vogar_args="$vogar_args --vm-command=$android_root/bin/art"
+ device_mode=true
vogar_args="$vogar_args --vm-arg -Ximage:/data/art-test/core.art"
shift
elif [[ "$1" == "--mode=host" ]]; then
@@ -131,6 +135,10 @@
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
@@ -138,6 +146,23 @@
fi
done
+if $device_mode; then
+ if $use_chroot; then
+ vogar_args="$vogar_args --device-dir=/tmp"
+ vogar_args="$vogar_args --vm-command=/system/bin/art"
+ else
+ 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
+fi
+
# Increase the timeout, as vogar cannot set individual test
# timeout when being asked to run packages, and some tests go above
# the default timeout.