From: Damir Tomic Date: Thu, 25 Jun 2015 10:16:34 +0000 (+0200) Subject: nameresolution.cpp~a54f29b6c06a0baf: X-Git-Tag: NTP_4_2_8P3_RC3~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff33d6b1d7ca7ff0fb65927f7ff6087adf717a9c;p=thirdparty%2Fntp.git nameresolution.cpp~a54f29b6c06a0baf: Delete: sntp/tests/nameresolution.cpp bk: 558bd502DRXtm1dXPdW5mfKvneng4w --- diff --git a/sntp/tests/nameresolution.cpp b/sntp/tests/nameresolution.cpp deleted file mode 100644 index 9b48189c8..000000000 --- a/sntp/tests/nameresolution.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "g_sntptest.h" - -extern "C" { -#include "networking.h" -}; - -class networkingTest : public sntptest { -protected: - ::testing::AssertionResult CompareAddrinfo(const char* host, - int family, int flags, - const addrinfo& actual) { - if (family != actual.ai_family) - return ::testing::AssertionFailure() - << "Family mismatch, expected: " << family - << " but was: " << actual.ai_family; - sockaddr_u* sock = new sockaddr_u; - void* expectedaddr = NULL, *actualaddr = NULL; - int size = 0, addrsize = 0; - if (family == AF_INET) { - expectedaddr = &sock->sa4.sin_addr; - actualaddr = &((sockaddr_u*)actual.ai_addr)->sa4.sin_addr; - size = sizeof(sock->sa4); - addrsize = sizeof(sock->sa4.sin_addr); - } else { - expectedaddr = &sock->sa6.sin6_addr; - actualaddr = &((sockaddr_u*)actual.ai_addr)->sa6.sin6_addr; - size = sizeof(sock->sa6); - addrsize = sizeof(sock->sa6.sin6_addr); - } - sock->sa.sa_family = family; - - if (inet_pton(family, host, expectedaddr) != 1) - return ::testing::AssertionFailure() - << "inet_pton failed!"; - - if (flags != actual.ai_flags) - return ::testing::AssertionFailure() - << "Flags mismatch, expected: " << flags - << " but was: " << actual.ai_flags; - - if (size != actual.ai_addrlen) - return ::testing::AssertionFailure() - << "Address length mismatch, expected: " << size - << " but was: " << actual.ai_addrlen; - - if (memcmp(expectedaddr, actualaddr, addrsize) != 0) - return ::testing::AssertionFailure() - << "Address mismatch"; - return ::testing::AssertionSuccess(); - } -}; - -TEST_F(networkingTest, ResolveSingleAddress) { - const char* HOSTS[1] = {"192.0.2.1"}; - const int HOSTCOUNT = COUNTOF(HOSTS); - - addrinfo** actual = NULL; - - ASSERT_EQ(1, resolve_hosts(HOSTS, HOSTCOUNT, &actual, PF_UNSPEC)); - - ASSERT_TRUE(actual != NULL); - EXPECT_TRUE(CompareAddrinfo(HOSTS[0], AF_INET, 0, **actual)); -} - -TEST_F(networkingTest, ResolveMultipleAddresses) { - const char* HOSTS[3] = {"192.0.2.1", "192.0.2.5", "192.0.2.10"}; - const int HOSTCOUNT = COUNTOF(HOSTS); - - addrinfo** actual = NULL; - - ASSERT_EQ(3, resolve_hosts(HOSTS, HOSTCOUNT, &actual, PF_UNSPEC)); - - ASSERT_TRUE(actual != NULL); - for (int i=0; i