summaryrefslogtreecommitdiff
path: root/libartpalette/apex/palette_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libartpalette/apex/palette_test.cc')
-rw-r--r--libartpalette/apex/palette_test.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 63072c491b..d42a60685a 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 <cstring>
#include <filesystem>
#ifdef ART_TARGET_ANDROID
@@ -50,6 +51,14 @@ bool PaletteSetTaskProfilesIsSupported(palette_status_t res) {
<< "Device API level: " << android_get_device_api_level();
return false;
}
+bool PaletteDebugStoreIsSupported(palette_status_t res) {
+ if (android::modules::sdklevel::IsAtLeastV()) {
+ return true;
+ }
+ EXPECT_EQ(PALETTE_STATUS_NOT_SUPPORTED, res)
+ << "Device API level: " << android_get_device_api_level();
+ return false;
+}
#endif
} // namespace
@@ -166,3 +175,24 @@ TEST_F(PaletteClientTest, SetTaskProfilesCpp) {
}
#endif
}
+
+TEST_F(PaletteClientTest, DebugStore) {
+#ifndef ART_TARGET_ANDROID
+ GTEST_SKIP() << "DebugStore is only supported on Android";
+#else
+ std::array<char, 20> result{};
+ palette_status_t pstatus = PaletteDebugStoreGetString(result.data(), result.size());
+ // Make sure the we are on a correct API level.
+ if (PaletteDebugStoreIsSupported(pstatus)) {
+ EXPECT_EQ(PALETTE_STATUS_OK, pstatus);
+
+ size_t len = strnlen(result.data(), result.size());
+ EXPECT_TRUE(len < result.size());
+
+ const char* start = "1,0,";
+ const char* end = "::";
+ EXPECT_TRUE(len > strlen(start) + strlen(end));
+ EXPECT_EQ(strncmp(result.data() + len - strlen(end), end, strlen(end)), 0);
+ }
+#endif
+}