Merge "storaged: skip disk_stats test if not supported." am: c232e0af05 am: 43373678d9

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1912710

Change-Id: I14a1940f15f4ba17d7566251b476d72c5b43fa45
diff --git a/storaged/Android.bp b/storaged/Android.bp
index f2366cf..7960af3 100644
--- a/storaged/Android.bp
+++ b/storaged/Android.bp
@@ -115,6 +115,9 @@
     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 e987f76..bb71bf3 100644
--- a/storaged/tests/storaged_test.cpp
+++ b/storaged/tests/storaged_test.cpp
@@ -25,6 +25,7 @@
 
 #include <gtest/gtest.h>
 
+#include <aidl/android/hardware/health/IHealth.h>
 #include <healthhalutils/HealthHalUtils.h>
 #include <storaged.h>               // data structures
 #include <storaged_utils.h>         // functions to test
@@ -249,6 +250,13 @@
     // 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<aidl::android::hardware::health::DiskStats> 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