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
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