aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIoannis Ilkos <ilkos@google.com>2023-03-03 10:32:08 +0000
committerMartin Stjernholm <mast@google.com>2023-03-07 19:06:18 +0000
commit2f6374b3860e67dcdee63b53d86bcf09e0849ff1 (patch)
tree64171c87b1abb49ec4bd814914f0ef71a626e190
parent2a7f2b335e8f4032dca63b18a76d0bbd8ea22b16 (diff)
downloadperfetto-2f6374b3860e67dcdee63b53d86bcf09e0849ff1.tar.gz
Check platform version in java heap dump OOME tests
If this is to be used by MTS, it needs to be version-aware Test: atest Change-Id: I5229640c13ecead24efafafd1073d8989c6f4e05 Bug: 270986537 Merged-In: I5229640c13ecead24efafafd1073d8989c6f4e05
-rw-r--r--test/cts/heapprofd_java_test_cts.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/test/cts/heapprofd_java_test_cts.cc b/test/cts/heapprofd_java_test_cts.cc
index ca6016127..40c4aa69c 100644
--- a/test/cts/heapprofd_java_test_cts.cc
+++ b/test/cts/heapprofd_java_test_cts.cc
@@ -20,6 +20,8 @@
#include <sys/wait.h>
#include "perfetto/base/logging.h"
+#include "perfetto/ext/base/android_utils.h"
+#include "perfetto/ext/base/string_utils.h"
#include "perfetto/tracing/core/data_source_config.h"
#include "src/base/test/test_task_runner.h"
#include "test/android_test_utils.h"
@@ -34,6 +36,22 @@
namespace perfetto {
namespace {
+// Even though ART is a mainline module, there are dependencies on perfetto for
+// OOM heap dumps to work correctly.
+bool SupportsOomHeapDump() {
+ auto sdk = base::StringToInt32(base::GetAndroidProp("ro.build.version.sdk"));
+ if (sdk && *sdk >= 34) {
+ PERFETTO_LOG("SDK supports OOME heap dumps");
+ return true;
+ }
+ if (base::GetAndroidProp("ro.build.version.codename") == "UpsideDownCake") {
+ PERFETTO_LOG("Codename supports OOME heap dumps");
+ return true;
+ }
+ PERFETTO_LOG("OOME heap dumps not supported");
+ return false;
+}
+
std::string RandomSessionName() {
std::random_device rd;
std::default_random_engine generator(rd());
@@ -237,22 +255,27 @@ TEST(HeapprofdJavaCtsTest, DebuggableAppRuntimeByPid) {
TEST(HeapprofdJavaCtsTest, DebuggableAppOom) {
std::string app_name = "android.perfetto.cts.app.debuggable";
const auto& packets = TriggerOomHeapDump(app_name, "*");
- AssertGraphPresent(packets);
+ if (SupportsOomHeapDump()) {
+ AssertGraphPresent(packets);
+ }
}
TEST(HeapprofdJavaCtsTest, ProfileableAppOom) {
std::string app_name = "android.perfetto.cts.app.profileable";
const auto& packets = TriggerOomHeapDump(app_name, "*");
- AssertGraphPresent(packets);
+ if (SupportsOomHeapDump()) {
+ AssertGraphPresent(packets);
+ }
}
TEST(HeapprofdJavaCtsTest, ReleaseAppOom) {
std::string app_name = "android.perfetto.cts.app.release";
const auto& packets = TriggerOomHeapDump(app_name, "*");
- if (!IsUserBuild())
- AssertGraphPresent(packets);
- else
+ if (IsUserBuild()) {
AssertNoProfileContents(packets);
+ } else if (SupportsOomHeapDump()) {
+ AssertGraphPresent(packets);
+ }
}
TEST(HeapprofdJavaCtsTest, DebuggableAppOomNotSelected) {