diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/c-ares/test/ares-test-live.cc | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/c-ares/test/ares-test-live.cc')
-rw-r--r-- | contrib/libs/c-ares/test/ares-test-live.cc | 242 |
1 files changed, 121 insertions, 121 deletions
diff --git a/contrib/libs/c-ares/test/ares-test-live.cc b/contrib/libs/c-ares/test/ares-test-live.cc index 5510163e95..7d27cbc9d4 100644 --- a/contrib/libs/c-ares/test/ares-test-live.cc +++ b/contrib/libs/c-ares/test/ares-test-live.cc @@ -18,70 +18,70 @@ unsigned char gdns_addr4[4] = {0x08, 0x08, 0x08, 0x08}; unsigned char gdns_addr6[16] = {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}; -MATCHER_P(IncludesAtLeastNumAddresses, n, "") { - if(!arg) - return false; - int cnt = 0; - for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) - cnt++; - return cnt >= n; -} - -MATCHER_P(OnlyIncludesAddrType, addrtype, "") { - if(!arg) - return false; - for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) - if (ai->ai_family != addrtype) - return false; - return true; -} - -MATCHER_P(IncludesAddrType, addrtype, "") { - if(!arg) - return false; - for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) - if (ai->ai_family == addrtype) - return true; - return false; -} - -//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoV4) { - //struct ares_addrinfo_hints hints = {}; - //hints.ai_family = AF_INET; - //AddrInfoResult result; - //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); - //Process(); - //EXPECT_TRUE(result.done_); - //EXPECT_EQ(ARES_SUCCESS, result.status_); - //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(1)); - //EXPECT_THAT(result.ai_, OnlyIncludesAddrType(AF_INET)); -//} - -//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoV6) { - //struct ares_addrinfo_hints hints = {}; - //hints.ai_family = AF_INET6; - //AddrInfoResult result; - //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); - //Process(); - //EXPECT_TRUE(result.done_); - //EXPECT_EQ(ARES_SUCCESS, result.status_); - //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(1)); - //EXPECT_THAT(result.ai_, OnlyIncludesAddrType(AF_INET6)); -//} - -//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoUnspec) { - //struct ares_addrinfo_hints hints = {}; - //hints.ai_family = AF_UNSPEC; - //AddrInfoResult result; - //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); - //Process(); - //EXPECT_TRUE(result.done_); - //EXPECT_EQ(ARES_SUCCESS, result.status_); - //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(2)); - //EXPECT_THAT(result.ai_, IncludesAddrType(AF_INET6)); - //EXPECT_THAT(result.ai_, IncludesAddrType(AF_INET)); -//} - +MATCHER_P(IncludesAtLeastNumAddresses, n, "") { + if(!arg) + return false; + int cnt = 0; + for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) + cnt++; + return cnt >= n; +} + +MATCHER_P(OnlyIncludesAddrType, addrtype, "") { + if(!arg) + return false; + for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) + if (ai->ai_family != addrtype) + return false; + return true; +} + +MATCHER_P(IncludesAddrType, addrtype, "") { + if(!arg) + return false; + for (const ares_addrinfo_node* ai = arg->nodes; ai != NULL; ai = ai->ai_next) + if (ai->ai_family == addrtype) + return true; + return false; +} + +//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoV4) { + //struct ares_addrinfo_hints hints = {}; + //hints.ai_family = AF_INET; + //AddrInfoResult result; + //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); + //Process(); + //EXPECT_TRUE(result.done_); + //EXPECT_EQ(ARES_SUCCESS, result.status_); + //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(1)); + //EXPECT_THAT(result.ai_, OnlyIncludesAddrType(AF_INET)); +//} + +//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoV6) { + //struct ares_addrinfo_hints hints = {}; + //hints.ai_family = AF_INET6; + //AddrInfoResult result; + //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); + //Process(); + //EXPECT_TRUE(result.done_); + //EXPECT_EQ(ARES_SUCCESS, result.status_); + //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(1)); + //EXPECT_THAT(result.ai_, OnlyIncludesAddrType(AF_INET6)); +//} + +//VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetAddrInfoUnspec) { + //struct ares_addrinfo_hints hints = {}; + //hints.ai_family = AF_UNSPEC; + //AddrInfoResult result; + //ares_getaddrinfo(channel_, "www.google.com.", NULL, &hints, AddrInfoCallback, &result); + //Process(); + //EXPECT_TRUE(result.done_); + //EXPECT_EQ(ARES_SUCCESS, result.status_); + //EXPECT_THAT(result.ai_, IncludesAtLeastNumAddresses(2)); + //EXPECT_THAT(result.ai_, IncludesAddrType(AF_INET6)); + //EXPECT_THAT(result.ai_, IncludesAddrType(AF_INET)); +//} + VIRT_NONVIRT_TEST_F(DefaultChannelTest, DISABLED_LiveGetHostByNameV4) { HostResult result; ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); @@ -214,11 +214,11 @@ TEST_P(DefaultChannelModeTest, LiveGetLocalhostByAddrV4) { EXPECT_EQ(ARES_SUCCESS, result.status_); EXPECT_LT(0, (int)result.host_.addrs_.size()); EXPECT_EQ(AF_INET, result.host_.addrtype_); - // oddly, travis does not resolve to localhost, but a random hostname starting with travis-job - if (result.host_.name_.find("travis-job") == std::string::npos) { - EXPECT_NE(std::string::npos, - result.host_.name_.find("localhost")); - } + // oddly, travis does not resolve to localhost, but a random hostname starting with travis-job + if (result.host_.name_.find("travis-job") == std::string::npos) { + EXPECT_NE(std::string::npos, + result.host_.name_.find("localhost")); + } } } @@ -234,9 +234,9 @@ TEST_P(DefaultChannelModeTest, LiveGetLocalhostByAddrV6) { EXPECT_EQ(ARES_SUCCESS, result.status_); EXPECT_LT(0, (int)result.host_.addrs_.size()); EXPECT_EQ(AF_INET6, result.host_.addrtype_); - const std::string& name = result.host_.name_; - EXPECT_TRUE(std::string::npos != name.find("localhost") || - std::string::npos != name.find("ip6-loopback")); + const std::string& name = result.host_.name_; + EXPECT_TRUE(std::string::npos != name.find("localhost") || + std::string::npos != name.find("ip6-loopback")); } } @@ -696,54 +696,54 @@ TEST_F(DefaultChannelTest, VerifySocketFunctionCallback) { } -TEST_F(DefaultChannelTest, LiveSetServers) { - struct ares_addr_node server1; - struct ares_addr_node server2; - server1.next = &server2; - server1.family = AF_INET; - server1.addr.addr4.s_addr = htonl(0x01020304); - server2.next = nullptr; - server2.family = AF_INET; - server2.addr.addr4.s_addr = htonl(0x02030405); - - // Change not allowed while request is pending - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - EXPECT_EQ(ARES_ENOTIMP, ares_set_servers(channel_, &server1)); - ares_cancel(channel_); -} - -TEST_F(DefaultChannelTest, LiveSetServersPorts) { - struct ares_addr_port_node server1; - struct ares_addr_port_node server2; - server1.next = &server2; - server1.family = AF_INET; - server1.addr.addr4.s_addr = htonl(0x01020304); - server1.udp_port = 111; - server1.tcp_port = 111; - server2.next = nullptr; - server2.family = AF_INET; - server2.addr.addr4.s_addr = htonl(0x02030405); - server2.udp_port = 0; - server2.tcp_port = 0;; - EXPECT_EQ(ARES_ENODATA, ares_set_servers_ports(nullptr, &server1)); - - // Change not allowed while request is pending - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_ports(channel_, &server1)); - ares_cancel(channel_); -} - -TEST_F(DefaultChannelTest, LiveSetServersCSV) { - // Change not allowed while request is pending - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_csv(channel_, "1.2.3.4,2.3.4.5")); - EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_ports_csv(channel_, "1.2.3.4:56,2.3.4.5:67")); - ares_cancel(channel_); -} - - +TEST_F(DefaultChannelTest, LiveSetServers) { + struct ares_addr_node server1; + struct ares_addr_node server2; + server1.next = &server2; + server1.family = AF_INET; + server1.addr.addr4.s_addr = htonl(0x01020304); + server2.next = nullptr; + server2.family = AF_INET; + server2.addr.addr4.s_addr = htonl(0x02030405); + + // Change not allowed while request is pending + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + EXPECT_EQ(ARES_ENOTIMP, ares_set_servers(channel_, &server1)); + ares_cancel(channel_); +} + +TEST_F(DefaultChannelTest, LiveSetServersPorts) { + struct ares_addr_port_node server1; + struct ares_addr_port_node server2; + server1.next = &server2; + server1.family = AF_INET; + server1.addr.addr4.s_addr = htonl(0x01020304); + server1.udp_port = 111; + server1.tcp_port = 111; + server2.next = nullptr; + server2.family = AF_INET; + server2.addr.addr4.s_addr = htonl(0x02030405); + server2.udp_port = 0; + server2.tcp_port = 0;; + EXPECT_EQ(ARES_ENODATA, ares_set_servers_ports(nullptr, &server1)); + + // Change not allowed while request is pending + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_ports(channel_, &server1)); + ares_cancel(channel_); +} + +TEST_F(DefaultChannelTest, LiveSetServersCSV) { + // Change not allowed while request is pending + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_csv(channel_, "1.2.3.4,2.3.4.5")); + EXPECT_EQ(ARES_ENOTIMP, ares_set_servers_ports_csv(channel_, "1.2.3.4:56,2.3.4.5:67")); + ares_cancel(channel_); +} + + } // namespace test } // namespace ares |