Test for unexpected prefix updates in SetAndClearNat64Prefix.
Add code to check that no onNat64PrefixEvent calls were sent by
the resolver other than the ones expected by the test.
This adds a simple counter of unexpected events to the test
DnsMetricsListener. It does not offer the ability to check which
events occur and in what order, but it does at least not require
adding timeouts to ensure that the unexpected events do not
occur.
Bug: 156914456
Test: test-only change
Original-Change: https://android-review.googlesource.com/1313745
Merged-In: Ic86f93161293b4ad5366fd9cab2e26d4a6f636c4
Change-Id: Ic86f93161293b4ad5366fd9cab2e26d4a6f636c4
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp
index d70a552..595d621 100644
--- a/tests/resolv_integration_test.cpp
+++ b/tests/resolv_integration_test.cpp
@@ -185,7 +185,11 @@
static void TearDownTestSuite() { AIBinder_DeathRecipient_delete(sResolvDeathRecipient); }
protected:
- void SetUp() { mDnsClient.SetUp(); }
+ void SetUp() {
+ mDnsClient.SetUp();
+ sDnsMetricsListener->reset();
+ }
+
void TearDown() {
// Ensure the dump works at the end of each test.
DumpResolverService();
@@ -3816,6 +3820,8 @@
EXPECT_TRUE(resolvService->stopPrefix64Discovery(TEST_NETID).isOk());
EXPECT_TRUE(WaitForNat64Prefix(EXPECT_NOT_FOUND));
+
+ EXPECT_EQ(0, sDnsMetricsListener->getUnexpectedNat64PrefixUpdates());
}
namespace {