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/ti-agent/common_helper.h b/test/ti-agent/common_helper.h
index 8599fc4..c60553d 100644
--- a/test/ti-agent/common_helper.h
+++ b/test/ti-agent/common_helper.h
@@ -71,6 +71,12 @@
 
 bool JvmtiErrorToException(JNIEnv* env, jvmtiError error);
 
+// Load the class through JNI. Inspect it, find all native methods. Construct the corresponding
+// mangled name, run dlsym and bind the method.
+//
+// This will abort on failure.
+void BindFunctions(jvmtiEnv* jvmti_env, JNIEnv* env, const char* class_name);
+
 }  // namespace art
 
 #endif  // ART_TEST_TI_AGENT_COMMON_HELPER_H_