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

Commit 57997e80 authored by Ken Chen's avatar Ken Chen
Browse files

[Test] Fix MTS failure on GetAddrinfo_BlockDnsQueryWithUidRule

The test has different expected behavior when the device under test has
the libcom.android.tethering.dns_helper and does not have the library.
The test needs to check whether the libcom.android.tethering.dns_helper
is installed or not.

Bug: 309164580
Test: atest resolv_integration_test:ResolverTest#GetAddrinfo_BlockDnsQue
ryWithUidRule

Change-Id: I0b54224634e873374566fa5bf83c9d0af352e84d
parent 6bcd0ff2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ cc_test {
        "libnetd_test_resolv_utils",
        "libnetdutils",
        "libssl",
        "libc++fs",
        "libcutils",
        "netd_aidl_interface-lateststable-ndk",
        "netd_event_listener_interface-lateststable-ndk",
+5 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@

#include <algorithm>
#include <chrono>
#include <filesystem>
#include <functional>
#include <iterator>
#include <numeric>
@@ -127,6 +128,8 @@ using android::netdutils::ScopedAddrinfo;
using android::netdutils::Stopwatch;
using android::netdutils::toHex;

namespace fs = std::filesystem;

namespace {

std::pair<ScopedAddrinfo, int> safe_getaddrinfo_time_taken(const char* node, const char* service,
@@ -4505,9 +4508,9 @@ TEST_F(ResolverTest, GetAddrinfo_BlockDnsQueryWithUidRule) {
        const char* hname;
        const int expectedErrorCode;
    } kTestData[] = {
            {host_name, isAtLeastT() ? EAI_FAIL : EAI_NODATA},
            {host_name, (isAtLeastT() && fs::exists(DNS_HELPER)) ? EAI_FAIL : EAI_NODATA},
            // To test the query with search domain.
            {"howdy", isAtLeastT() ? EAI_FAIL : EAI_AGAIN},
            {"howdy", (isAtLeastT() && fs::exists(DNS_HELPER)) ? EAI_FAIL : EAI_AGAIN},
    };

    INetd* netdService = mDnsClient.netdService();
+5 −0
Original line number Diff line number Diff line
@@ -437,3 +437,8 @@ void RemoveMdnsRoute();
            GTEST_SKIP() << "Skipping test because SDK version is less than T."; \
        }                                                                        \
    } while (0)

static const std::string DNS_HELPER =
        android::bpf::isUserspace64bit()
                ? "/apex/com.android.tethering/lib64/libcom.android.tethering.dns_helper.so"
                : "/apex/com.android.tethering/lib/libcom.android.tethering.dns_helper.so";