summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2023-01-05 00:15:54 +0000
committer Martin Stjernholm <mast@google.com> 2023-01-09 14:24:30 +0000
commit3962633b60d5be335a0745ec4abe766ee468d903 (patch)
treed55d94401e4c871ce0e3834096859dbd784e91d0
parentdaa9be44dcdc6a9b46db23a5e0bc0008c09a074c (diff)
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
-rw-r--r--libartpalette/apex/palette_test.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 853dc29f58..0bcc09329b 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 @@ TEST_F(PaletteClientTest, Ashmem) {
#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
}