From 1407fd04dbd2c4b1295dc2857cd094618f204528 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 6 Dec 2021 23:04:12 -0800 Subject: [PATCH] storaged: skip disk_stats test if not supported. If HAL does not support disk stats, do not run corresponding storaged tests. Also add storaged-unit-tests to Treehugger. Test: storaged-unit-tests Bug: 208543110 Change-Id: Ia2acf30ca3e259e0f0744385da69d92f9c00f223 --- storaged/Android.bp | 3 +++ storaged/tests/storaged_test.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/storaged/Android.bp b/storaged/Android.bp index f2366cff1..7960af314 100644 --- a/storaged/Android.bp +++ b/storaged/Android.bp @@ -115,6 +115,9 @@ cc_test { static_libs: [ "libstoraged", ], + test_suites: [ + "general-tests", + ], } // AIDL interface between storaged and framework.jar diff --git a/storaged/tests/storaged_test.cpp b/storaged/tests/storaged_test.cpp index e987f76f2..bb71bf3c2 100644 --- a/storaged/tests/storaged_test.cpp +++ b/storaged/tests/storaged_test.cpp @@ -25,6 +25,7 @@ #include +#include #include #include // data structures #include // functions to test @@ -249,6 +250,13 @@ TEST(storaged_test, disk_stats_monitor) { // testing if detect() will return the right value disk_stats_monitor dsm_detect{healthService}; ASSERT_TRUE(dsm_detect.enabled()); + + // Even if enabled(), healthService may not support disk stats. Check if it is supported. + std::vector halStats; + if (healthService->getDiskStats(&halStats).getExceptionCode() == EX_UNSUPPORTED_OPERATION) { + GTEST_SKIP(); + } + // feed monitor with constant perf data for io perf baseline // using constant perf is reasonable since the functionality of stream_stats // has already been tested