From 90c4e26b9f847f12dda2bdc7006496d61675a54f Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Thu, 5 Oct 2023 15:47:54 +0000 Subject: [PATCH] lmkd/tests: do not fail when occasionally reaping time is reported as 0 In rare cases the process reaping time is short enough that it is reported as 0. Prevent the test from failing in this rare case. Bug: 296555636 Change-Id: I8484958eb9561ba345008195be8b6a7bd94e9ef3 Signed-off-by: Suren Baghdasaryan --- tests/lmkd_tests.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/lmkd_tests.cpp b/tests/lmkd_tests.cpp index 5cf7d0b..2537a9d 100644 --- a/tests/lmkd_tests.cpp +++ b/tests/lmkd_tests.cpp @@ -228,12 +228,15 @@ TEST_F(LmkdTest, TargetReaping) { line = logcat_out.substr( line_start, line_end == std::string::npos ? std::string::npos : line_end - line_start); long reap_time; - ASSERT_TRUE(ParseReapTime(line, pid, reap_time) && reap_time > 0) + ASSERT_TRUE(ParseReapTime(line, pid, reap_time) && reap_time >= 0) << "Reaping time report format is invalid"; - double reclaim_speed = ((double)rss + swap) / reap_time; - GTEST_LOG_(INFO) << "Reclaim speed " << reclaim_speed << "kB/ms (" << rss << "kB rss + " << swap - << "kB swap) / " << reap_time << "ms"; + // occasionally the reaping happens quickly enough that it's reported as 0ms + if (reap_time > 0) { + double reclaim_speed = ((double)rss + swap) / reap_time; + GTEST_LOG_(INFO) << "Reclaim speed " << reclaim_speed << "kB/ms (" << rss << "kB rss + " + << swap << "kB swap) / " << reap_time << "ms"; + } } int main(int argc, char** argv) {