summaryrefslogtreecommitdiff
path: root/auto_tests/network_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/network_test.c')
-rw-r--r--auto_tests/network_test.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index c1ac8084..b88b0e8c 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -28,7 +28,7 @@ START_TEST(test_addr_resolv_localhost)
28 int localhost_split = 0; 28 int localhost_split = 0;
29 29
30 IP ip; 30 IP ip;
31 ip_init(&ip, 0); 31 ip_init(&ip, 0); // ipv6enabled = 0
32 32
33 int res = addr_resolve(localhost, &ip, NULL); 33 int res = addr_resolve(localhost, &ip, NULL);
34 34
@@ -39,10 +39,10 @@ START_TEST(test_addr_resolv_localhost)
39 ck_assert_msg(ip.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(ip.ip4.in_addr)); 39 ck_assert_msg(ip.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(ip.ip4.in_addr));
40 } 40 }
41 41
42 ip_init(&ip, 1); 42 ip_init(&ip, 1); // ipv6enabled = 1
43 res = addr_resolve(localhost, &ip, NULL); 43 res = addr_resolve(localhost, &ip, NULL);
44 44
45 if (res < 1) { 45 if (!(res & TOX_ADDR_RESOLVE_INET6)) {
46 res = addr_resolve("ip6-localhost", &ip, NULL); 46 res = addr_resolve("ip6-localhost", &ip, NULL);
47 localhost_split = 1; 47 localhost_split = 1;
48 } 48 }
@@ -50,12 +50,12 @@ START_TEST(test_addr_resolv_localhost)
50 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 50 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
51 51
52 if (res > 0) { 52 if (res > 0) {
53 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6, got %u.", ip.family); 53 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
54 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip)); 54 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip));
55 } 55 }
56 56
57 if (!localhost_split) { 57 if (!localhost_split) {
58 ip_init(&ip, 1); 58 ip_init(&ip, 1); // ipv6enabled = 1
59 ip.family = AF_UNSPEC; 59 ip.family = AF_UNSPEC;
60 IP extra; 60 IP extra;
61 ip_reset(&extra); 61 ip_reset(&extra);
@@ -63,10 +63,10 @@ START_TEST(test_addr_resolv_localhost)
63 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno)); 63 ck_assert_msg(res > 0, "Resolver failed: %u, %s (%x, %x)", errno, strerror(errno));
64 64
65 if (res > 0) { 65 if (res > 0) {
66 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6, got %u.", ip.family); 66 ck_assert_msg(ip.family == AF_INET6, "Expected family AF_INET6 (%u), got %u.", AF_INET6, ip.family);
67 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip)); 67 ck_assert_msg(!memcmp(&ip.ip6, &in6addr_loopback, sizeof(IP6)), "Expected ::1, got %s.", ip_ntoa(&ip));
68 68
69 ck_assert_msg(extra.family == AF_INET, "Expected family AF_INET, got %u.", extra.family); 69 ck_assert_msg(extra.family == AF_INET, "Expected family AF_INET (%u), got %u.", AF_INET, extra.family);
70 ck_assert_msg(extra.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(extra.ip4.in_addr)); 70 ck_assert_msg(extra.ip4.uint32 == htonl(0x7F000001), "Expected 127.0.0.1, got %s.", inet_ntoa(extra.ip4.in_addr));
71 } 71 }
72 } else { 72 } else {
@@ -144,7 +144,7 @@ Suite *network_suite(void)
144 return s; 144 return s;
145} 145}
146 146
147int main(int argc, char *argv[]) 147int main()
148{ 148{
149 srand((unsigned int) time(NULL)); 149 srand((unsigned int) time(NULL));
150 150