diff options
author | Mike Yu <yumike@google.com> | 2023-08-04 08:33:02 +0000 |
---|---|---|
committer | Mike Yu <yumike@google.com> | 2023-08-07 08:23:24 +0000 |
commit | 3d955a93853234e6ec9731947b2797b20b5bd5e9 (patch) | |
tree | 70e19db6a255d06fe410c8752dc708d201466997 | |
parent | 7656f2009012f1e6ced77d262e4012c3ec61f00a (diff) | |
download | DnsResolver-3d955a93853234e6ec9731947b2797b20b5bd5e9.tar.gz |
Test: Catch all Nat64PrefixUpdates in PrefixDiscoveryBypassTls
The test PrefixDiscoveryBypassTls expects DnsResolver to trigger
onNat64PrefixEvent 4 times (2 for prefix-added events; 2 for
prefix-removed events) , but it doesn't catch all of the event
before it ends. This will cause the next test SetAndClearNat64Prefix
to fail if the last onNat64PrefixEvent is received after
SetAndClearNat64Prefix runs.
This change improves PrefixDiscoveryBypassTls to ensure that all
onNat64PrefixEvents are caught before the test ends.
Bug: 293833962
Test: ran PrefixDiscoveryBypassTls and SetAndClearNat64Prefix together
300 times
Change-Id: I09de58b957679602fae2c9be1caa1e7f0fa29c21
-rw-r--r-- | tests/resolv_integration_test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp index 8623e153..0c2a0bd0 100644 --- a/tests/resolv_integration_test.cpp +++ b/tests/resolv_integration_test.cpp @@ -4124,6 +4124,9 @@ TEST_F(ResolverTest, PrefixDiscoveryBypassTls) { EXPECT_EQ(0, tls.queries()) << dns.dumpQueries(); EXPECT_EQ(1U, GetNumQueries(dns, dns64_name)) << dns.dumpQueries(); + EXPECT_TRUE(mDnsClient.resolvService()->stopPrefix64Discovery(TEST_NETID).isOk()); + EXPECT_TRUE(WaitForNat64Prefix(EXPECT_NOT_FOUND)); + // Restart the testing network to reset the cache. mDnsClient.TearDown(); mDnsClient.SetUp(); @@ -4147,6 +4150,16 @@ TEST_F(ResolverTest, PrefixDiscoveryBypassTls) { // Verify it bypassed TLS despite STRICT mode. EXPECT_EQ(0, tls.queries()) << dns.dumpQueries(); EXPECT_EQ(1U, GetNumQueries(dns, dns64_name)) << dns.dumpQueries(); + + // Stop the prefix discovery to make DnsResolver send the prefix-removed event + // earlier. Without this, DnsResolver still sends the event once the network + // is destroyed; however, it will fail the next test if the test unexpectedly + // receives the event that it doesn't want. + EXPECT_TRUE(mDnsClient.resolvService()->stopPrefix64Discovery(TEST_NETID).isOk()); + EXPECT_TRUE(WaitForNat64Prefix(EXPECT_NOT_FOUND)); + + EXPECT_EQ(0, sDnsMetricsListener->getUnexpectedNat64PrefixUpdates()); + EXPECT_EQ(0, sUnsolicitedEventListener->getUnexpectedNat64PrefixUpdates()); } TEST_F(ResolverTest, SetAndClearNat64Prefix) { |