Do not use CommonRuntimeTest in art_standalone_libartpalette_tests.
It makes us link against non-public APIs in libart, which we cannot do
in CTS.
Bug: 262840076
Test: atest -a art_standalone_libartpalette_tests
Test: m test-art-host-gtest-art_libartpalette_tests
Change-Id: I2c2b221a28ed6cb9563ba1f001d434e75e422882
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 853dc29..0bcc093 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -21,7 +21,6 @@
#include <sys/syscall.h>
#include <unistd.h>
-#include "common_runtime_test.h"
#include "gtest/gtest.h"
namespace {
@@ -70,14 +69,32 @@
#endif
}
-class PaletteClientJniTest : public art::CommonRuntimeTest {};
-
-TEST_F(PaletteClientJniTest, JniInvocation) {
+TEST_F(PaletteClientTest, JniInvocation) {
+#ifndef ART_TARGET_ANDROID
+ // On host we need to set up a boot classpath and pass it in here. Let's not
+ // bother since this test is only for native API coverage on target.
+ GTEST_SKIP() << "Will only spin up a VM on Android";
+#else
bool enabled;
EXPECT_EQ(PALETTE_STATUS_OK, PaletteShouldReportJniInvocations(&enabled));
- JNIEnv* env = art::Thread::Current()->GetJniEnv();
+ JavaVMInitArgs vm_args;
+ JavaVMOption options[] = {
+ {.optionString = "-verbose:jni", .extraInfo = nullptr},
+ };
+ vm_args.version = JNI_VERSION_1_6;
+ vm_args.nOptions = std::size(options);
+ vm_args.options = options;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+
+ JavaVM* jvm = nullptr;
+ JNIEnv* env = nullptr;
+ EXPECT_EQ(JNI_OK, JNI_CreateJavaVM(&jvm, &env, &vm_args));
ASSERT_NE(nullptr, env);
+
PaletteNotifyBeginJniInvocation(env);
PaletteNotifyEndJniInvocation(env);
+
+ EXPECT_EQ(JNI_OK, jvm->DestroyJavaVM());
+#endif
}