ART: Refactor TI tests
Add a helper to explicitly bind native methods in a given class,
using dlsym to look up C functions in the local environment.
Add a callback helper that hooks VmInit and calls the above function
on the Main class. Use the callback helper before calling the test-
defined or shared minimal OnLoad function.
Add a binder helper that immediately binds the Main functions. Use
the helper before calling the test-defined OnAttach function.
Remove System.loadLibrary from tests. Instead rely on the explicit
binding.
In preparation for making the tests functional on device.
Test: m test-art-host
Change-Id: I12e68f070e8c6331e51d3a1fa4b9ebd8f28dfce6
diff --git a/test/911-get-stack-trace/stack_trace.cc b/test/911-get-stack-trace/stack_trace.cc
index d162e8a..68f6d8d 100644
--- a/test/911-get-stack-trace/stack_trace.cc
+++ b/test/911-get-stack-trace/stack_trace.cc
@@ -34,6 +34,14 @@
using android::base::StringPrintf;
+extern "C" JNIEXPORT void JNICALL Java_Main_bindTest911Classes(
+ JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) {
+ BindFunctions(jvmti_env, env, "AllTraces");
+ BindFunctions(jvmti_env, env, "Frames");
+ BindFunctions(jvmti_env, env, "PrintThread");
+ BindFunctions(jvmti_env, env, "ThreadListTraces");
+}
+
static jint FindLineNumber(jint line_number_count,
jvmtiLineNumberEntry* line_number_table,
jlocation location) {