diff options
Diffstat (limited to 'auto_tests/network_test.c')
-rw-r--r-- | auto_tests/network_test.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c index 200c04db..4713528d 100644 --- a/auto_tests/network_test.c +++ b/auto_tests/network_test.c | |||
@@ -38,7 +38,7 @@ START_TEST(test_addr_resolv_localhost) | |||
38 | 38 | ||
39 | char ip_str[IP_NTOA_LEN]; | 39 | char ip_str[IP_NTOA_LEN]; |
40 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); | 40 | ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); |
41 | const uint32_t loopback = net_htonl(IP4_LOOPBACK.uint32); | 41 | const uint32_t loopback = get_ip4_loopback().uint32; |
42 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", | 42 | ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", |
43 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 43 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
44 | 44 | ||
@@ -53,7 +53,8 @@ START_TEST(test_addr_resolv_localhost) | |||
53 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); | 53 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); |
54 | 54 | ||
55 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 55 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
56 | ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.", | 56 | IP6 ip6_loopback = get_ip6_loopback(); |
57 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", | ||
57 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 58 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
58 | 59 | ||
59 | if (localhost_split) { | 60 | if (localhost_split) { |
@@ -69,7 +70,7 @@ START_TEST(test_addr_resolv_localhost) | |||
69 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); | 70 | ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); |
70 | 71 | ||
71 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); | 72 | ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); |
72 | ck_assert_msg(!memcmp(&ip.ip6, &IP6_LOOPBACK, sizeof(IP6)), "Expected ::1, got %s.", | 73 | ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", |
73 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); | 74 | ip_ntoa(&ip, ip_str, sizeof(ip_str))); |
74 | 75 | ||
75 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); | 76 | ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); |
@@ -127,7 +128,8 @@ START_TEST(test_ip_equal) | |||
127 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " | 128 | ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::ffff:127.0.0.1} ): " |
128 | "expected result != 0, got 0."); | 129 | "expected result != 0, got 0."); |
129 | 130 | ||
130 | memcpy(&ip2.ip6, &IP6_LOOPBACK, sizeof(IP6)); | 131 | IP6 ip6_loopback = get_ip6_loopback(); |
132 | memcpy(&ip2.ip6, &ip6_loopback, sizeof(IP6)); | ||
131 | res = ip_equal(&ip1, &ip2); | 133 | res = ip_equal(&ip1, &ip2); |
132 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); | 134 | ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); |
133 | 135 | ||