Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eef17ad7 authored by Mike Yu's avatar Mike Yu
Browse files

Test: Create single PrivateDnsConfiguration in PrivateDnsConfigurationTest and make it static

Creating a PrivateDnsConfigurationTest for each test occasionally
causes the DoT validation thread to access a PrivateDnsConfiguration
that no longer exits, which causes the test to crash.

To fix the crash, change the test to create a single PrivateDnsConfiguration
for all tests in PrivateDnsConfigurationTest and make its lifetime
as long as resolv_unit_test to ensure the PrivateDnsConfiguration
object is always alive for all DoT validation threads.

Bug: 283705283
Test: ran resolv_unit_test
Change-Id: Ia3a706af85d12fa955a961da34060bc7e80d18c5
parent ca0ecb95
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -81,7 +81,11 @@ class PrivateDnsConfigurationTest : public NetNativeTestBase {
        EXPECT_EQ(0, resolv_create_cache_for_net(kNetId));
    }

    void TearDown() { resolv_delete_cache_for_net(kNetId); }
    void TearDown() {
        // Reset the state for the next test.
        resolv_delete_cache_for_net(kNetId);
        mPdc.set(kNetId, kMark, {}, {}, {}, {});
    }

  protected:
    class MockObserver : public PrivateDnsValidationObserver {
@@ -135,7 +139,7 @@ class PrivateDnsConfigurationTest : public NetNativeTestBase {
    static constexpr char kServer2[] = "127.0.2.3";

    MockObserver mObserver;
    PrivateDnsConfiguration mPdc;
    inline static PrivateDnsConfiguration mPdc;

    // TODO: Because incorrect CAs result in validation failed in strict mode, have
    // PrivateDnsConfiguration run mocked code rather than DnsTlsTransport::validate().