summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2023-12-21 18:15:12 +0000
committer Martin Stjernholm <mast@google.com> 2023-12-21 18:20:02 +0000
commit4f99d9d39f8048ae4c2b359da054b1bb059820fa (patch)
tree863807babdbd6e7de7f7a9e6341f68d2b3b6e275
parentf25a0e493ecc9e7613343711deca235fc8e704be (diff)
Reapply "Construct BCP arguments to the VM using CommonArtTest code." am: e08696f240
This reverts commit 80ad5692c923dae191669994d92fd2784890633a, reversing changes made to a68c25f524066105346499a2347c15ac6391fe94. https://r.android.com/2883706 wasn't intended to go into AOSP main. Test: m art_libartpalette_tests art_standalone_libartpalette_tests Bug: 306064090 Bug: 288212464 Change-Id: Id9b2c24c8fb2169f50ff2ab37ff77c3d45cbf219
-rw-r--r--libartpalette/apex/palette_test.cc30
1 files changed, 17 insertions, 13 deletions
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 9273e51cf1..c2b7304d8d 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -28,6 +28,7 @@
#include "android/api-level.h"
#endif
+#include "base/common_art_test.h"
#include "gtest/gtest.h"
namespace {
@@ -96,23 +97,27 @@ TEST_F(PaletteClientTest, Ashmem) {
#endif
}
-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
+class PaletteClientJniTest : public art::CommonArtTest {};
+
+TEST_F(PaletteClientJniTest, JniInvocation) {
bool enabled;
EXPECT_EQ(PALETTE_STATUS_OK, PaletteShouldReportJniInvocations(&enabled));
- JavaVMInitArgs vm_args;
+ std::string boot_class_path_string =
+ GetClassPathOption("-Xbootclasspath:", GetLibCoreDexFileNames());
+ std::string boot_class_path_locations_string =
+ GetClassPathOption("-Xbootclasspath-locations:", GetLibCoreDexLocations());
+
JavaVMOption options[] = {
- {.optionString = "-verbose:jni", .extraInfo = nullptr},
+ {.optionString = boot_class_path_string.c_str(), .extraInfo = nullptr},
+ {.optionString = boot_class_path_locations_string.c_str(), .extraInfo = nullptr},
+ };
+ JavaVMInitArgs vm_args = {
+ .version = JNI_VERSION_1_6,
+ .nOptions = std::size(options),
+ .options = options,
+ .ignoreUnrecognized = JNI_TRUE,
};
- 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;
@@ -123,7 +128,6 @@ TEST_F(PaletteClientTest, JniInvocation) {
PaletteNotifyEndJniInvocation(env);
EXPECT_EQ(JNI_OK, jvm->DestroyJavaVM());
-#endif
}
TEST_F(PaletteClientTest, SetTaskProfiles) {