ART: Add slow-debug test in 004-JniTest
Ensure that run-tests (in debug mode) run with slow flags enabled.
Bug: 35644369
Test: m test-art-host
Change-Id: Ib2146ee7f20fad484c86d967113e38bb1d6ed075
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc
index 81be531..f2edd0f 100644
--- a/test/004-JniTest/jni_test.cc
+++ b/test/004-JniTest/jni_test.cc
@@ -775,5 +775,18 @@
return a + b + c;
}
+extern "C" JNIEXPORT jboolean JNICALL Java_Main_isSlowDebug(JNIEnv*, jclass) {
+ // Return whether slow-debug is on. Only relevant for debug builds.
+ if (kIsDebugBuild) {
+ // Register a dummy flag and get the default value it should be initialized with.
+ static bool dummy_flag = false;
+ dummy_flag = RegisterRuntimeDebugFlag(&dummy_flag);
+
+ return dummy_flag ? JNI_TRUE : JNI_FALSE;
+ }
+ // To pass the Java-side test, just so "on" for release builds.
+ return JNI_TRUE;
+}
+
} // namespace art
diff --git a/test/004-JniTest/src/Main.java b/test/004-JniTest/src/Main.java
index bb098e4..0c4ed89 100644
--- a/test/004-JniTest/src/Main.java
+++ b/test/004-JniTest/src/Main.java
@@ -24,6 +24,11 @@
public class Main {
public static void main(String[] args) {
System.loadLibrary(args[0]);
+
+ if (!isSlowDebug()) {
+ throw new RuntimeException("Slow-debug flags unexpectedly off.");
+ }
+
testFindClassOnAttachedNativeThread();
testFindFieldOnAttachedNativeThread();
testReflectFieldGetFromAttachedNativeThreadNative();
@@ -307,6 +312,8 @@
}
}
}
+
+ private static native boolean isSlowDebug();
}
@FunctionalInterface