CTS: Use ART's libctstiagent
Use helper functions from ART's test code.
Bug: 32072923
Test: m cts
Test: cts-tradefed run cts-dev --module CtsJvmtiTrackingHostTestCases
Test: cts-tradefed run cts-dev --module CtsJvmtiTaggingHostTestCases
Test: cts-tradefed run cts-dev --module CtsJvmtiRedefineClassesHostTestCases
Change-Id: I961242ebd27a45506aa6eb1db937ea21a06dc113
diff --git a/hostsidetests/jvmti/base/jni/tracking.cpp b/hostsidetests/jvmti/base/jni/tracking.cpp
index a46f491..a07d653 100644
--- a/hostsidetests/jvmti/base/jni/tracking.cpp
+++ b/hostsidetests/jvmti/base/jni/tracking.cpp
@@ -21,14 +21,12 @@
#include "android-base/logging.h"
#include "android-base/stringprintf.h"
-#include "common.h"
#include "jvmti_helper.h"
#include "scoped_local_ref.h"
#include "scoped_utf_chars.h"
+#include "test_env.h"
-namespace cts {
-namespace jvmti {
-namespace allocation_tracking {
+namespace art {
static std::string GetClassName(JNIEnv* jni_env, jclass cls) {
ScopedLocalRef<jclass> class_class(jni_env, jni_env->GetObjectClass(cls));
@@ -65,17 +63,17 @@
memset(&callbacks, 0, sizeof(jvmtiEventCallbacks));
callbacks.VMObjectAlloc = enable ? ObjectAllocated : nullptr;
- jvmtiError ret = GetJvmtiEnv()->SetEventCallbacks(&callbacks, sizeof(callbacks));
- JvmtiErrorToException(env, GetJvmtiEnv(), ret);
+ jvmtiError ret = jvmti_env->SetEventCallbacks(&callbacks, sizeof(callbacks));
+ JvmtiErrorToException(env, jvmti_env, ret);
}
extern "C" JNIEXPORT void JNICALL Java_android_jvmti_cts_JvmtiTrackingTest_enableAllocationTracking(
JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jthread thread, jboolean enable) {
- jvmtiError ret = GetJvmtiEnv()->SetEventNotificationMode(
+ jvmtiError ret = jvmti_env->SetEventNotificationMode(
enable ? JVMTI_ENABLE : JVMTI_DISABLE,
JVMTI_EVENT_VM_OBJECT_ALLOC,
thread);
- JvmtiErrorToException(env, GetJvmtiEnv(), ret);
+ JvmtiErrorToException(env, jvmti_env, ret);
}
extern "C" JNIEXPORT
@@ -95,6 +93,4 @@
return env->NewStringUTF(result.c_str());
}
-} // namespace allocation_tracking
-} // namespace jvmti
-} // namespace cts
+} // namespace art