Add test coverage for DnsResolverService::dump()

The thing that calling the dump() at the end of every integration test
can help reduce the possibility of resolver service crash when dump
is being called. This is important especially when bugreport is being
taken.

cd packages/modules/DnsResolver && atest

Change-Id: Iec114a4de4082314496c9f7a3769db51ef42d857
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp
index a9bce8b..8b05cda 100644
--- a/tests/resolv_integration_test.cpp
+++ b/tests/resolv_integration_test.cpp
@@ -163,7 +163,12 @@
     };
 
     void SetUp() { mDnsClient.SetUp(); }
-    void TearDown() { mDnsClient.TearDown(); }
+    void TearDown() {
+        // Ensure the dump works at the end of each test.
+        DumpResolverService();
+
+        mDnsClient.TearDown();
+    }
 
     void StartDns(test::DNSResponder& dns, const std::vector<DnsRecord>& records) {
         for (const auto& r : records) {
@@ -174,6 +179,14 @@
         dns.clearQueries();
     }
 
+    void DumpResolverService() {
+        unique_fd fd(open("/dev/null", O_WRONLY));
+        EXPECT_EQ(mDnsClient.resolvService()->dump(fd, nullptr, 0), 0);
+
+        const char* querylogCmd[] = {"querylog"};  // Keep it sync with DnsQueryLog::DUMP_KEYWORD.
+        EXPECT_EQ(mDnsClient.resolvService()->dump(fd, querylogCmd, std::size(querylogCmd)), 0);
+    }
+
     bool WaitForNat64Prefix(ExpectNat64PrefixStatus status,
                             std::chrono::milliseconds timeout = std::chrono::milliseconds(1000)) {
         return sDnsMetricsListener->waitForNat64Prefix(status, timeout);