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

Commit a65c72b6 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by Gerrit Code Review
Browse files

Merge changes from topic "DNS_test_w_bpf" into main

* changes:
  [Test] Run BlockDnsQuery only when dependency is fulfilled
  [Test] Fix MTS failure on GetAddrinfo_BlockDnsQueryWithUidRule
parents 4780bd1f ed9a0b7e
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",
+4 −2
Original line number Diff line number Diff line
@@ -127,6 +127,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 +4507,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();
+2 −0
Original line number Diff line number Diff line
@@ -552,6 +552,8 @@ TEST_P(TransportParameterizedTest, MdnsGetAddrInfo_fallback) {

TEST_P(TransportParameterizedTest, BlockDnsQuery) {
    SKIP_IF_BEFORE_T;
    SKIP_IF_DEPENDENT_LIB_DOES_NOT_EXIST(DNS_HELPER);

    constexpr char ptr_name[] = "v4v6.example.com.";
    // PTR record for IPv6 address 2001:db8::102:304
    constexpr char ptr_addr_v6[] =
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <arpa/nameser.h>
#include <netdb.h>

#include <filesystem>
#include <functional>
#include <string>
#include <vector>
@@ -437,3 +438,14 @@ 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";

#define SKIP_IF_DEPENDENT_LIB_DOES_NOT_EXIST(libPath)                  \
    do {                                                               \
        if (!std::filesystem::exists(libPath))                         \
            GTEST_SKIP() << "Required " << (libPath) << " not found."; \
    } while (0)