Enable some redefinition run-tests in CTS
We added the tests to run-test-jvmti-java-library
target and made some small changes to tests to
ensure that everything works without linking to
libart.so.
Bug: 32072923
Test: ./test.py --host -j40
Change-Id: I8fdad180c77b125c22c043cd61305cee79801cc7
diff --git a/test/945-obsolete-native/obsolete_native.cc b/test/945-obsolete-native/obsolete_native.cc
index 64e2e8b..e3090f5 100644
--- a/test/945-obsolete-native/obsolete_native.cc
+++ b/test/945-obsolete-native/obsolete_native.cc
@@ -19,17 +19,13 @@
#include <stdio.h>
#include "android-base/stringprintf.h"
-
-#include "android-base/stringprintf.h"
-#include "base/logging.h"
-#include "base/macros.h"
#include "jni.h"
#include "jvmti.h"
-#include "scoped_local_ref.h"
// Test infrastructure
#include "jni_binder.h"
#include "test_env.h"
+#include "scoped_local_ref.h"
namespace art {
namespace Test945ObsoleteNative {
@@ -37,7 +33,6 @@
extern "C" JNIEXPORT void JNICALL Java_art_Test945_00024Transform_doExecute(
JNIEnv* env, jclass klass ATTRIBUTE_UNUSED, jobject runnable) {
jclass runnable_klass = env->FindClass("java/lang/Runnable");
- DCHECK(runnable_klass != nullptr);
jmethodID run_method = env->GetMethodID(runnable_klass, "run", "()V");
env->CallVoidMethod(runnable, run_method);
}
diff --git a/test/984-obsolete-invoke/obsolete_invoke.cc b/test/984-obsolete-invoke/obsolete_invoke.cc
index 1768f45..ab2499a 100644
--- a/test/984-obsolete-invoke/obsolete_invoke.cc
+++ b/test/984-obsolete-invoke/obsolete_invoke.cc
@@ -17,13 +17,12 @@
#include "android-base/macros.h"
#include "jni.h"
#include "jvmti.h"
-#include "mirror/class-inl.h"
-#include "scoped_local_ref.h"
// Test infrastructure
#include "test_env.h"
#include "jvmti_helper.h"
+#include "scoped_local_ref.h"
namespace art {
namespace Test984ObsoleteInvoke {
diff --git a/test/Android.bp b/test/Android.bp
index 7cf49e2..c5d96da 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -250,6 +250,7 @@
"ti-agent/jni_binder.cc",
"ti-agent/jvmti_helper.cc",
"ti-agent/test_env.cc",
+ "ti-agent/common_helper.cc",
// This is the list of non-special OnLoad things and excludes BCI and anything that depends
// on ART internals.
"903-hello-tagging/tagging.cc",
@@ -272,6 +273,8 @@
"929-search/search.cc",
"931-agent-thread/agent_thread.cc",
"933-misc-events/misc_events.cc",
+ "945-obsolete-native/obsolete_native.cc",
+ "984-obsolete-invoke/obsolete_invoke.cc",
],
shared_libs: [
"libbase",
@@ -287,17 +290,14 @@
// This is to get the IsInterpreted native method.
"common/stack_inspect.cc",
"common/runtime_state.cc",
+ "ti-agent/common_load.cc",
// This includes the remaining test functions. We should try to refactor things to
// make this list smaller.
- "ti-agent/common_helper.cc",
- "ti-agent/common_load.cc",
"901-hello-ti-agent/basics.cc",
"909-attach-agent/attach.cc",
"912-classes/classes.cc",
"936-search-onload/search_onload.cc",
- "945-obsolete-native/obsolete_native.cc",
"983-source-transform-verify/source_transform.cc",
- "984-obsolete-invoke/obsolete_invoke.cc",
],
}
diff --git a/test/Android.run-test-jvmti-java-library.mk b/test/Android.run-test-jvmti-java-library.mk
index b6da92b..dcb238c 100644
--- a/test/Android.run-test-jvmti-java-library.mk
+++ b/test/Android.run-test-jvmti-java-library.mk
@@ -18,13 +18,17 @@
include $(CLEAR_VARS)
-# Main shim classes. We use one that exposes the tagging common functionality.
-LOCAL_MAIN_SHIM := 903-hello-tagging/src/art/Main.java
-LOCAL_SRC_FILES := $(LOCAL_MAIN_SHIM)
+# shim classes. We use one that exposes the common functionality.
+LOCAL_SHIM_CLASSES := \
+ 902-hello-transformation/src/art/Redefinition.java \
+ 903-hello-tagging/src/art/Main.java \
+
+LOCAL_SRC_FILES := $(LOCAL_SHIM_CLASSES)
# Actual test classes.
LOCAL_SRC_FILES += \
901-hello-ti-agent/src/art/Test901.java \
+ 902-hello-transformation/src/art/Test902.java \
903-hello-tagging/src/art/Test903.java \
904-object-allocation/src/art/Test904.java \
905-object-free/src/art/Test905.java \
@@ -42,19 +46,36 @@
911-get-stack-trace/src/art/SameThread.java \
911-get-stack-trace/src/art/ThreadListTraces.java \
913-heaps/src/art/Test913.java \
+ 914-hello-obsolescence/src/art/Test914.java \
+ 915-obsolete-2/src/art/Test915.java \
+ 917-fields-transformation/src/art/Test917.java \
918-fields/src/art/Test918.java \
+ 919-obsolete-fields/src/art/Test919.java \
920-objects/src/art/Test920.java \
922-properties/src/art/Test922.java \
923-monitors/src/art/Test923.java \
924-threads/src/art/Test924.java \
925-threadgroups/src/art/Test925.java \
+ 926-multi-obsolescence/src/art/Test926.java \
927-timers/src/art/Test927.java \
928-jni-table/src/art/Test928.java \
+ 930-hello-retransform/src/art/Test930.java \
931-agent-thread/src/art/Test931.java \
+ 932-transform-saves/src/art/Test932.java \
933-misc-events/src/art/Test933.java \
+ 940-recursive-obsolete/src/art/Test940.java \
+ 942-private-recursive/src/art/Test942.java \
+ 944-transform-classloaders/src/art/Test944.java \
+ 945-obsolete-native/src/art/Test945.java \
+ 947-reflect-method/src/art/Test947.java \
+ 951-threaded-obsolete/src/art/Test951.java \
+ 981-dedup-original-dex/src/art/Test981.java \
+ 982-ok-no-retransform/src/art/Test982.java \
+ 984-obsolete-invoke/src/art/Test984.java \
JVMTI_RUN_TEST_GENERATED_NUMBERS := \
901 \
+ 902 \
903 \
904 \
905 \
@@ -64,16 +85,32 @@
910 \
911 \
913 \
+ 914 \
+ 915 \
+ 917 \
918 \
+ 919 \
920 \
922 \
923 \
924 \
925 \
+ 926 \
927 \
928 \
+ 930 \
931 \
+ 932 \
933 \
+ 940 \
+ 942 \
+ 944 \
+ 945 \
+ 947 \
+ 951 \
+ 981 \
+ 982 \
+ 984 \
# Try to enforce that the directories correspond to the Java files we pull in.
JVMTI_RUN_TEST_DIR_CHECK := $(sort $(foreach DIR,$(JVMTI_RUN_TEST_GENERATED_NUMBERS), \
diff --git a/test/ti-agent/common_helper.cc b/test/ti-agent/common_helper.cc
index dc9e26d..bfd4d25 100644
--- a/test/ti-agent/common_helper.cc
+++ b/test/ti-agent/common_helper.cc
@@ -369,6 +369,7 @@
cb.ClassFileLoadHook = common_retransform::CommonClassFileLoadHookRetransformable;
jvmtiError res = jvmti_env->SetEventCallbacks(&cb, sizeof(cb));
CHECK_EQ(res, JVMTI_ERROR_NONE);
+ common_retransform::gTransformations.clear();
}
static void SetupCommonTransform() {
@@ -385,6 +386,7 @@
cb.ClassFileLoadHook = common_retransform::CommonClassFileLoadHookRetransformable;
jvmtiError res = jvmti_env->SetEventCallbacks(&cb, sizeof(cb));
CHECK_EQ(res, JVMTI_ERROR_NONE);
+ common_retransform::gTransformations.clear();
}
extern "C" JNIEXPORT void JNICALL Java_art_Redefinition_nativeSetTestConfiguration(JNIEnv*,