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

Commit a11b93bd authored by Luke Huang's avatar Luke Huang Committed by Automerger Merge Worker
Browse files

Fix flaky test Async_EmptyAnswer am: b29545b9

Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/1749266

Change-Id: I4503fc8a0998fd75bcd21971bb8a6cfaffee7aed
parents 0fafed44 b29545b9
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -2414,13 +2414,16 @@ TEST_F(ResolverTest, Async_EmptyAnswer) {
        EXPECT_EQ(std::cv_status::no_timeout, cv.wait_for(lk, std::chrono::seconds(1)));
    }

    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, 0, "howdy.example.com", {"::1.2.3.4"});
    dns.setResponseProbability(0.0);

    int fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", ns_c_in, ns_t_a, 0);
    EXPECT_TRUE(fd2 != -1);
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, RCODE_TIMEOUT, "howdy.example.com", {});

    int fd3 = resNetworkQuery(TEST_NETID, "howdy.example.com", ns_c_in, ns_t_a, 0);
    EXPECT_TRUE(fd3 != -1);
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, RCODE_TIMEOUT, "howdy.example.com", {});

    uint8_t buf[MAXPACKET] = {};
    int rcode;
@@ -2438,6 +2441,7 @@ TEST_F(ResolverTest, Async_EmptyAnswer) {

    int fd4 = resNetworkQuery(TEST_NETID, "howdy.example.com", ns_c_in, ns_t_a, 0);
    EXPECT_TRUE(fd4 != -1);
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, 0, "howdy.example.com", {"1.2.3.4"});

    memset(buf, 0, MAXPACKET);
    res = getAsyncResponse(fd4, &rcode, buf, MAXPACKET);
@@ -2448,12 +2452,6 @@ TEST_F(ResolverTest, Async_EmptyAnswer) {
    res = getAsyncResponse(fd1, &rcode, buf, MAXPACKET);
    EXPECT_GT(res, 0);
    EXPECT_EQ("::1.2.3.4", toString(buf, res, AF_INET6));

    // Trailing dot is removed. Is it intended?
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, 0, "howdy.example.com", {"::1.2.3.4"});
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, RCODE_TIMEOUT, "howdy.example.com", {});
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, RCODE_TIMEOUT, "howdy.example.com", {});
    ExpectDnsEvent(INetdEventListener::EVENT_RES_NSEND, 0, "howdy.example.com", {"1.2.3.4"});
}

TEST_F(ResolverTest, Async_MalformedQuery) {