runtime: Add -Xverify:softfail and ART_TEST_INTERPRETER_ACCESS_CHECKS
Use ART_TEST_INTERPRETER_ACCESS_CHECKS=true to run all the tests through
the interpreter with access checks enabled. The normal interpreter tests
do not currently enable access checks, which means that a large part of
the interpreter codebase is untested.
The verifier will force every class into a soft fail mode if
-Xverify:softfail is used, thereby ensuring that if used along with the
interpreter (-Xint) that the interpret is always in access checks mode.
This is used alongside with --compile-filter=verify-at-runtime to
prevent the AOT compiler from putting down any code.
Change-Id: I35a10ed8c43d76fa96133cf01fdad497da387200
diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk
index 65ddf8d..3d5c483 100644
--- a/test/Android.run-test.mk
+++ b/test/Android.run-test.mk
@@ -112,6 +112,9 @@
ifeq ($(ART_TEST_DEFAULT_COMPILER),true)
COMPILER_TYPES += default
endif
+ifeq ($(ART_TEST_INTERPRETER_ACCESS_CHECKS),true)
+ COMPILER_TYPES += interpreter-access-checks
+endif
ifeq ($(ART_TEST_INTERPRETER),true)
COMPILER_TYPES += interpreter
endif
@@ -260,6 +263,28 @@
TEST_ART_BROKEN_NO_RELOCATE_TESTS :=
+# Temporarily disable some broken tests when forcing access checks in interpreter b/22414682
+TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS := \
+ 004-JniTest \
+ 005-annotations \
+ 044-proxy \
+ 073-mismatched-field \
+ 088-monitor-verification \
+ 135-MirandaDispatch \
+ 137-cfi \
+ 412-new-array \
+ 471-uninitialized-locals \
+ 506-verify-aput \
+ 800-smali
+
+ifneq (,$(filter interpreter-access-checks,$(COMPILER_TYPES)))
+ ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(RUN_TYPES),$(PREBUILD_TYPES), \
+ interpreter-access-checks,$(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \
+ $(IMAGE_TYPES), $(PICTEST_TYPES), $(DEBUGGABLE_TYPES), $(TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS), $(ALL_ADDRESS_SIZES))
+endif
+
+TEST_ART_BROKEN_INTERPRETER_ACCESS_CHECK_TESTS :=
+
# Tests that are broken with GC stress.
# 137-cfi needs to unwind a second forked process. We're using a primitive sleep to wait till we
# hope the second process got into the expected state. The slowness of gcstress makes this bad.
@@ -604,7 +629,8 @@
# Create a rule to build and run a tests following the form:
# test-art-{1: host or target}-run-test-{2: debug ndebug}-{3: prebuild no-prebuild no-dex2oat}-
-# {4: interpreter default optimizing jit}-{5: relocate nrelocate relocate-npatchoat}-
+# {4: interpreter default optimizing jit interpreter-access-checks}-
+# {5: relocate nrelocate relocate-npatchoat}-
# {6: trace or ntrace}-{7: gcstress gcverify cms}-{8: forcecopy checkjni jni}-
# {9: no-image image picimage}-{10: pictest npictest}-
# {11: ndebuggable debuggable}-{12: test name}{13: 32 or 64}
@@ -674,6 +700,9 @@
ifeq ($(4),interpreter)
test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_RULES
run_test_options += --interpreter
+ else ifeq ($(4),interpreter-access-checks)
+ test_groups += ART_RUN_TEST_$$(uc_host_or_target)_INTERPRETER_ACCESS_CHECKS_RULES
+ run_test_options += --interpreter --verify-soft-fail
else
ifeq ($(4),default)
test_groups += ART_RUN_TEST_$$(uc_host_or_target)_DEFAULT_RULES
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 842d87e..db64b77 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -42,7 +42,7 @@
TIME_OUT_VALUE=10
USE_GDB="n"
USE_JVM="n"
-VERIFY="y"
+VERIFY="y" # y=yes,n=no,s=softfail
ZYGOTE=""
DEX_VERIFY=""
USE_DEX2OAT_AND_PATCHOAT="y"
@@ -149,6 +149,9 @@
elif [ "x$1" = "x--no-verify" ]; then
VERIFY="n"
shift
+ elif [ "x$1" = "x--verify-soft-fail" ]; then
+ VERIFY="s"
+ shift
elif [ "x$1" = "x--no-optimize" ]; then
OPTIMIZE="n"
shift
@@ -201,7 +204,11 @@
if [ "$VERIFY" = "y" ]; then
JVM_VERIFY_ARG="-Xverify:all"
msg "Performing verification"
- else
+ elif [ "$VERIFY" = "s" ]; then
+ JVM_VERIFY_ARG="Xverify:all"
+ DEX_VERIFY="-Xverify:softfail"
+ msg "Forcing verification to be soft fail"
+ else # VERIFY = "n"
DEX_VERIFY="-Xverify:none"
JVM_VERIFY_ARG="-Xverify:none"
msg "Skipping verification"
@@ -263,7 +270,10 @@
INT_OPTS="-Xint"
if [ "$VERIFY" = "y" ] ; then
COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=interpret-only"
- else
+ elif [ "$VERIFY" = "s" ]; then
+ COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-at-runtime"
+ DEX_VERIFY="${DEX_VERIFY} -Xverify:softfail"
+ else # VERIFY = "n"
COMPILE_FLAGS="${COMPILE_FLAGS} --compiler-filter=verify-none"
DEX_VERIFY="${DEX_VERIFY} -Xverify:none"
fi
diff --git a/test/run-test b/test/run-test
index bdf680b..eabbab3 100755
--- a/test/run-test
+++ b/test/run-test
@@ -262,6 +262,10 @@
elif [ "x$1" = "x--no-verify" ]; then
run_args="${run_args} --no-verify"
shift
+ elif [ "x$1" = "x--verify-soft-fail" ]; then
+ run_args="${run_args} --verify-soft-fail"
+ image_suffix="-interpreter-access-checks"
+ shift
elif [ "x$1" = "x--no-optimize" ]; then
run_args="${run_args} --no-optimize"
shift
@@ -520,6 +524,9 @@
echo " --optimizing Enable optimizing compiler (default)."
echo " --quick Use Quick compiler (off by default)."
echo " --no-verify Turn off verification (on by default)."
+ echo " --verify-soft-fail Force soft fail verification (off by default)."
+ echo " Verification is enabled if neither --no-verify"
+ echo " nor --verify-soft-fail is specified."
echo " --no-optimize Turn off optimization (on by default)."
echo " --no-precise Turn off precise GC (on by default)."
echo " --zygote Spawn the process from the Zygote." \