diff options
| author | 2017-06-21 21:51:33 -0700 | |
|---|---|---|
| committer | 2017-06-22 09:03:49 -0700 | |
| commit | 27aaf64499af34261ffd00de8e3920fe311642f0 (patch) | |
| tree | 4407f765f77f8b547d51cf831ab3b417b51dcbe6 | |
| parent | 46c4c850944dc96fad6227a7ad9081a48fc3d965 (diff) | |
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
| -rw-r--r-- | test/004-JniTest/jni_test.cc | 13 | ||||
| -rw-r--r-- | test/004-JniTest/src/Main.java | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/004-JniTest/jni_test.cc b/test/004-JniTest/jni_test.cc index 81be531e44..f2edd0f688 100644 --- a/test/004-JniTest/jni_test.cc +++ b/test/004-JniTest/jni_test.cc @@ -775,5 +775,18 @@ static jint Java_Main_intCriticalNativeMethod(jint a, jint b, jint c) { 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 bb098e44dc..0c4ed89f81 100644 --- a/test/004-JniTest/src/Main.java +++ b/test/004-JniTest/src/Main.java @@ -24,6 +24,11 @@ import dalvik.annotation.optimization.FastNative; 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 @@ public class Main { } } } + + private static native boolean isSlowDebug(); } @FunctionalInterface |