Fix false positive on res_stats checking in cache unit test
Utility function expectCacheStats() falsely pass while 'stats' is empty
in input parameter and not empty in cache.
Bug: 134897288
Change-Id: Ib623157301c01cffadc3c6db2c8e7c7146edeb13
diff --git a/resolv_cache_unit_test.cpp b/resolv_cache_unit_test.cpp
index 9f4d0af..997a58a 100644
--- a/resolv_cache_unit_test.cpp
+++ b/resolv_cache_unit_test.cpp
@@ -215,6 +215,11 @@
EXPECT_TRUE(params == expected.setup.params) << msg;
// res_stats checking.
+ if (expected.stats.size() == 0) {
+ for (int ns = 0; ns < nscount; ns++) {
+ EXPECT_EQ(0U, stats[ns].sample_count) << msg;
+ }
+ }
for (size_t i = 0; i < expected.stats.size(); i++) {
EXPECT_TRUE(stats[i] == expected.stats[i]) << msg;
}