Construct BCP arguments to the VM using CommonArtTest code.
Enable the test on host again that got disabled in
https://r.android.com/2375894.
Test: atest -a art_standalone_libartpalette_tests
Test: art/tools/run-gtests.sh \
/apex/com.android.art/bin/art/arm64/art_libartpalette_tests
in ART chroot
Test: m test-art-host-gtest-art_libartpalette_tests
Test: readelf -s --demangle -W \
out/target/product/armv8/testcases/art_libartpalette_tests.com.android.art.testing/arm64/art_libartpalette_tests
Check that "UND" symbols look reasonable and don't include ART
internals.
Bug: 265157782
Bug: 262840076
Change-Id: Ia44b17f2b524a361b6023d43ff5e513bf10b1193
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 0bcc093..9585d93 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -21,6 +21,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include "base/common_art_test.h"
#include "gtest/gtest.h"
namespace {
@@ -69,23 +70,27 @@
#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},
};
- vm_args.version = JNI_VERSION_1_6;
- vm_args.nOptions = std::size(options);
- vm_args.options = options;
- vm_args.ignoreUnrecognized = JNI_TRUE;
+ JavaVMInitArgs vm_args = {
+ .version = JNI_VERSION_1_6,
+ .nOptions = std::size(options),
+ .options = options,
+ .ignoreUnrecognized = JNI_TRUE,
+ };
JavaVM* jvm = nullptr;
JNIEnv* env = nullptr;
@@ -96,5 +101,4 @@
PaletteNotifyEndJniInvocation(env);
EXPECT_EQ(JNI_OK, jvm->DestroyJavaVM());
-#endif
}