Cleanup of redefinition testing
Move redefine logic into a single common function and perform some
other cleanup.
Test: mma -j40 test-art-host
Change-Id: I8618bda4f392b683ce198374066e356b87578e7b
diff --git a/test/ti-agent/common_load.cc b/test/ti-agent/common_load.cc
index a959482..2795cbc 100644
--- a/test/ti-agent/common_load.cc
+++ b/test/ti-agent/common_load.cc
@@ -23,9 +23,9 @@
#include "base/logging.h"
#include "base/macros.h"
#include "common_load.h"
+#include "common_helper.h"
#include "901-hello-ti-agent/basics.h"
-#include "902-hello-transformation/transform.h"
#include "903-hello-tagging/tagging.h"
#include "904-object-allocation/tracking.h"
#include "905-object-free/tracking_free.h"
@@ -54,7 +54,7 @@
// A list of all the agents we have for testing.
AgentLib agents[] = {
{ "901-hello-ti-agent", Test901HelloTi::OnLoad, nullptr },
- { "902-hello-transformation", Test902HelloTransformation::OnLoad, nullptr },
+ { "902-hello-transformation", common_redefine::OnLoad, nullptr },
{ "903-hello-tagging", Test903HelloTagging::OnLoad, nullptr },
{ "904-object-allocation", Test904ObjectAllocation::OnLoad, nullptr },
{ "905-object-free", Test905ObjectFree::OnLoad, nullptr },
@@ -95,6 +95,10 @@
return true;
}
+static void SetIsJVM(char* options) {
+ RuntimeIsJVM = strncmp(options, "jvm", 3) == 0;
+}
+
extern "C" JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM* vm, char* options, void* reserved) {
char* remaining_options = nullptr;
char* name_option = nullptr;
@@ -112,6 +116,7 @@
printf("agent: %s does not include an OnLoad method.\n", name_option);
return -3;
}
+ SetIsJVM(remaining_options);
return lib->load(vm, remaining_options, reserved);
}
@@ -132,6 +137,7 @@
printf("agent: %s does not include an OnAttach method.\n", name_option);
return -3;
}
+ SetIsJVM(remaining_options);
return lib->attach(vm, remaining_options, reserved);
}