Loading tests/resolv_integration_test.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -7871,3 +7871,19 @@ TEST_F(ResolverTest, NegativeValueInExperimentFlag) { EXPECT_EQ(config.expectedBaseTimeoutMsec, resolvInfo.value().params.base_timeout_msec); } } // Verify that DNS queries can be made for hostnames that exist in etc/hosts when the default // network is not set and the application does not specify a network. (See // NetworkController::isUidAllowed for implementation details.) TEST_F(ResolverTest, NetworkUnspecified_localhost) { ScopedDefaultNetwork scopedDefaultNetwork(mDnsClient.netdService(), NETID_UNSET); ScopedSetNetworkForProcess scopedSetNetworkForProcess(NETID_UNSET); ScopedAddrinfo result = safe_getaddrinfo(kLocalHost, nullptr, nullptr); EXPECT_TRUE(result != nullptr); EXPECT_EQ(kLocalHostAddr, ToString(result)); result = safe_getaddrinfo(kIp6LocalHost, nullptr, nullptr); EXPECT_TRUE(result != nullptr); EXPECT_EQ(kIp6LocalHostAddr, ToString(result)); } tests/resolv_test_utils.h +17 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,23 @@ class ScopedSystemProperties { std::string mStoredValue; }; class ScopedDefaultNetwork { using INetd = aidl::android::net::INetd; public: ScopedDefaultNetwork(INetd* netSrv, uid_t testDefaultNetwork) : mNetSrv(netSrv) { EXPECT_TRUE(mNetSrv->networkGetDefault(&mStoredDefaultNetwork).isOk()); EXPECT_TRUE(mNetSrv->networkSetDefault(testDefaultNetwork).isOk()); }; ~ScopedDefaultNetwork() { EXPECT_TRUE(mNetSrv->networkSetDefault(mStoredDefaultNetwork).isOk()); } private: INetd* mNetSrv; int mStoredDefaultNetwork; }; struct DnsRecord { std::string host_name; // host name ns_type type; // record type Loading Loading
tests/resolv_integration_test.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -7871,3 +7871,19 @@ TEST_F(ResolverTest, NegativeValueInExperimentFlag) { EXPECT_EQ(config.expectedBaseTimeoutMsec, resolvInfo.value().params.base_timeout_msec); } } // Verify that DNS queries can be made for hostnames that exist in etc/hosts when the default // network is not set and the application does not specify a network. (See // NetworkController::isUidAllowed for implementation details.) TEST_F(ResolverTest, NetworkUnspecified_localhost) { ScopedDefaultNetwork scopedDefaultNetwork(mDnsClient.netdService(), NETID_UNSET); ScopedSetNetworkForProcess scopedSetNetworkForProcess(NETID_UNSET); ScopedAddrinfo result = safe_getaddrinfo(kLocalHost, nullptr, nullptr); EXPECT_TRUE(result != nullptr); EXPECT_EQ(kLocalHostAddr, ToString(result)); result = safe_getaddrinfo(kIp6LocalHost, nullptr, nullptr); EXPECT_TRUE(result != nullptr); EXPECT_EQ(kIp6LocalHostAddr, ToString(result)); }
tests/resolv_test_utils.h +17 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,23 @@ class ScopedSystemProperties { std::string mStoredValue; }; class ScopedDefaultNetwork { using INetd = aidl::android::net::INetd; public: ScopedDefaultNetwork(INetd* netSrv, uid_t testDefaultNetwork) : mNetSrv(netSrv) { EXPECT_TRUE(mNetSrv->networkGetDefault(&mStoredDefaultNetwork).isOk()); EXPECT_TRUE(mNetSrv->networkSetDefault(testDefaultNetwork).isOk()); }; ~ScopedDefaultNetwork() { EXPECT_TRUE(mNetSrv->networkSetDefault(mStoredDefaultNetwork).isOk()); } private: INetd* mNetSrv; int mStoredDefaultNetwork; }; struct DnsRecord { std::string host_name; // host name ns_type type; // record type Loading