summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libartpalette/Android.bp33
-rw-r--r--libartpalette/apex/palette_test.cc25
-rw-r--r--test/Android.bp4
3 files changed, 50 insertions, 12 deletions
diff --git a/libartpalette/Android.bp b/libartpalette/Android.bp
index 89607219cc..29ce22bcc4 100644
--- a/libartpalette/Android.bp
+++ b/libartpalette/Android.bp
@@ -141,8 +141,7 @@ art_cc_defaults {
},
}
-// Version of ART gtest `art_libartpalette_tests` for host.
-// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
+// Version of API coverage test for host.
art_cc_test {
name: "art_libartpalette_tests",
defaults: [
@@ -153,17 +152,41 @@ art_cc_test {
device_supported: false,
}
-// Standalone version of ART gtest `art_libartpalette_tests`, not bundled with the ART APEX on
-// target.
+// MCTS test for API coverage. This test starts a VM to check the JNI
+// notification callbacks, so it should not use art_standalone_gtest_defaults,
+// which statically links a runtime via libart-gtest.
art_cc_test {
name: "art_standalone_libartpalette_tests",
defaults: [
- "art_standalone_gtest_defaults",
+ "art_standalone_test_defaults",
"art_libartpalette_tests_defaults",
],
+ static_libs: [
+ "libartbase-testing",
+ "libartpalette",
+ ],
+ shared_libs: [
+ "liblog",
+ // Bypass stubs to get access to the platform-only JniInvocation APIs.
+ // They're not NDK APIs, but have the same stability requirements.
+ "libnativehelper#impl",
+ ],
test_config_template: ":art-gtests-target-standalone-cts-template",
test_suites: [
"cts",
+ "general-tests",
"mcts-art",
+ "mts-art",
],
+
+ // Duplicated from art_standalone_gtest_defaults
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
}
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 1c4d133b65..a72e523365 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -23,12 +23,13 @@
#include <cstring>
-#include "base/common_art_test.h"
+#include "base/testing.h"
#include "gtest/gtest.h"
#ifdef ART_TARGET_ANDROID
#include "android-modules-utils/sdk_level.h"
#include "android/api-level.h"
+#include "nativehelper/JniInvocation.h"
#endif
namespace {
@@ -92,16 +93,25 @@ TEST_F(PaletteClientTest, Ashmem) {
#endif
}
-class PaletteClientJniTest : public art::CommonArtTest {};
-
-TEST_F(PaletteClientJniTest, JniInvocation) {
+TEST_F(PaletteClientTest, JniInvocation) {
+#ifndef ART_TARGET_ANDROID
+ // On host we need to use the runtime linked into the test to start a VM (e.g.
+ // by inheriting CommonArtTest), while on device it needs to launch the
+ // runtime through libnativehelper. Let's not bother on host since this test
+ // is only for native API coverage on device.
+ GTEST_SKIP() << "Will only spin up a VM on Android";
+#else
bool enabled;
EXPECT_EQ(PALETTE_STATUS_OK, PaletteShouldReportJniInvocations(&enabled));
+ // Load the default JNI_CreateJavaVM implementation, i.e., libart.so.
+ JniInvocation jni_invocation;
+ ASSERT_TRUE(jni_invocation.Init(/*library=*/ nullptr));
+
std::string boot_class_path_string =
- GetClassPathOption("-Xbootclasspath:", GetLibCoreDexFileNames());
- std::string boot_class_path_locations_string =
- GetClassPathOption("-Xbootclasspath-locations:", GetLibCoreDexLocations());
+ art::testing::GetClassPathOption("-Xbootclasspath:", art::testing::GetLibCoreDexFileNames());
+ std::string boot_class_path_locations_string = art::testing::GetClassPathOption(
+ "-Xbootclasspath-locations:", art::testing::GetLibCoreDexLocations());
JavaVMOption options[] = {
{.optionString = boot_class_path_string.c_str(), .extraInfo = nullptr},
@@ -123,6 +133,7 @@ TEST_F(PaletteClientJniTest, JniInvocation) {
PaletteNotifyEndJniInvocation(env);
EXPECT_EQ(JNI_OK, jvm->DestroyJavaVM());
+#endif
}
TEST_F(PaletteClientTest, SetTaskProfiles) {
diff --git a/test/Android.bp b/test/Android.bp
index d3084fe7d2..76559a92c4 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -363,6 +363,10 @@ art_cc_defaults {
},
},
static_libs: [
+ // This dependency links the whole runtime statically into the test. Note that the boot
+ // classpath is not (normally) bundled with the test, so if the runtime is used to actually
+ // start a VM it may load the boot classpath from the device. Depending on the test
+ // configuration, that may not be in sync with the statically linked runtime.
"libart-gtest",
],
version_script: ":art-standalone-gtest-version",