summaryrefslogtreecommitdiff
path: root/auto_tests/network_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-02-14 20:51:55 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-02-14 20:51:55 +0000
commit35f13ef51dbf99c3d45d04f572e9e88795df7ae6 (patch)
tree8213605775c5f749fdabe683fbdea9106a6c32c1 /auto_tests/network_test.c
parent17a0b617f299c34563960bd4e9ed9a88e76ba92f (diff)
Get rid of the only GNU extension we used.
Diffstat (limited to 'auto_tests/network_test.c')
-rw-r--r--auto_tests/network_test.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index 1885c81f..f05f0dbd 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -43,7 +43,7 @@ START_TEST(test_addr_resolv_localhost)
43 char ip_str[IP_NTOA_LEN]; 43 char ip_str[IP_NTOA_LEN];
44 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family); 44 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET, got %u.", ip.family);
45 const uint32_t loopback = get_ip4_loopback().uint32; 45 const uint32_t loopback = get_ip4_loopback().uint32;
46 ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", 46 ck_assert_msg(ip.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.",
47 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 47 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
48 48
49 ip_init(&ip, 1); // ipv6enabled = 1 49 ip_init(&ip, 1); // ipv6enabled = 1
@@ -58,7 +58,7 @@ START_TEST(test_addr_resolv_localhost)
58 58
59 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); 59 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family);
60 IP6 ip6_loopback = get_ip6_loopback(); 60 IP6 ip6_loopback = get_ip6_loopback();
61 ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", 61 ck_assert_msg(!memcmp(&ip.ip.v6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.",
62 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 62 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
63 63
64 if (localhost_split) { 64 if (localhost_split) {
@@ -75,15 +75,15 @@ START_TEST(test_addr_resolv_localhost)
75 75
76#if USE_IPV6 76#if USE_IPV6
77 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family); 77 ck_assert_msg(ip.family == TOX_AF_INET6, "Expected family TOX_AF_INET6 (%u), got %u.", TOX_AF_INET6, ip.family);
78 ck_assert_msg(!memcmp(&ip.ip6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.", 78 ck_assert_msg(!memcmp(&ip.ip.v6, &ip6_loopback, sizeof(IP6)), "Expected ::1, got %s.",
79 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 79 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
80 80
81 ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family); 81 ck_assert_msg(extra.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, extra.family);
82 ck_assert_msg(extra.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", 82 ck_assert_msg(extra.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.",
83 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 83 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
84#else 84#else
85 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, ip.family); 85 ck_assert_msg(ip.family == TOX_AF_INET, "Expected family TOX_AF_INET (%u), got %u.", TOX_AF_INET, ip.family);
86 ck_assert_msg(ip.ip4.uint32 == loopback, "Expected 127.0.0.1, got %s.", 86 ck_assert_msg(ip.ip.v4.uint32 == loopback, "Expected 127.0.0.1, got %s.",
87 ip_ntoa(&ip, ip_str, sizeof(ip_str))); 87 ip_ntoa(&ip, ip_str, sizeof(ip_str)));
88#endif 88#endif
89} 89}
@@ -106,32 +106,32 @@ START_TEST(test_ip_equal)
106 ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res); 106 ck_assert_msg(res == 0, "ip_equal(NULL, PTR): expected result 0, got %u.", res);
107 107
108 ip1.family = TOX_AF_INET; 108 ip1.family = TOX_AF_INET;
109 ip1.ip4.uint32 = net_htonl(0x7F000001); 109 ip1.ip.v4.uint32 = net_htonl(0x7F000001);
110 110
111 res = ip_equal(&ip1, &ip2); 111 res = ip_equal(&ip1, &ip2);
112 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_UNSPEC, 0} ): " 112 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_UNSPEC, 0} ): "
113 "expected result 0, got %u.", res); 113 "expected result 0, got %u.", res);
114 114
115 ip2.family = TOX_AF_INET; 115 ip2.family = TOX_AF_INET;
116 ip2.ip4.uint32 = net_htonl(0x7F000001); 116 ip2.ip.v4.uint32 = net_htonl(0x7F000001);
117 117
118 res = ip_equal(&ip1, &ip2); 118 res = ip_equal(&ip1, &ip2);
119 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.1} ): " 119 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.1} ): "
120 "expected result != 0, got 0."); 120 "expected result != 0, got 0.");
121 121
122 ip2.ip4.uint32 = net_htonl(0x7F000002); 122 ip2.ip.v4.uint32 = net_htonl(0x7F000002);
123 123
124 res = ip_equal(&ip1, &ip2); 124 res = ip_equal(&ip1, &ip2);
125 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.2} ): " 125 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET, 127.0.0.2} ): "
126 "expected result 0, got %u.", res); 126 "expected result 0, got %u.", res);
127 127
128 ip2.family = TOX_AF_INET6; 128 ip2.family = TOX_AF_INET6;
129 ip2.ip6.uint32[0] = 0; 129 ip2.ip.v6.uint32[0] = 0;
130 ip2.ip6.uint32[1] = 0; 130 ip2.ip.v6.uint32[1] = 0;
131 ip2.ip6.uint32[2] = net_htonl(0xFFFF); 131 ip2.ip.v6.uint32[2] = net_htonl(0xFFFF);
132 ip2.ip6.uint32[3] = net_htonl(0x7F000001); 132 ip2.ip.v6.uint32[3] = net_htonl(0x7F000001);
133 133
134 ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip6) != 0, 134 ck_assert_msg(IPV6_IPV4_IN_V6(ip2.ip.v6) != 0,
135 "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0."); 135 "IPV6_IPV4_IN_V6(::ffff:127.0.0.1): expected != 0, got 0.");
136 136
137 res = ip_equal(&ip1, &ip2); 137 res = ip_equal(&ip1, &ip2);
@@ -139,7 +139,7 @@ START_TEST(test_ip_equal)
139 "expected result != 0, got 0."); 139 "expected result != 0, got 0.");
140 140
141 IP6 ip6_loopback = get_ip6_loopback(); 141 IP6 ip6_loopback = get_ip6_loopback();
142 memcpy(&ip2.ip6, &ip6_loopback, sizeof(IP6)); 142 memcpy(&ip2.ip.v6, &ip6_loopback, sizeof(IP6));
143 res = ip_equal(&ip1, &ip2); 143 res = ip_equal(&ip1, &ip2);
144 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res); 144 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET, 127.0.0.1}, {TOX_AF_INET6, ::1} ): expected result 0, got %u.", res);
145 145
@@ -147,7 +147,7 @@ START_TEST(test_ip_equal)
147 res = ip_equal(&ip1, &ip2); 147 res = ip_equal(&ip1, &ip2);
148 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::1} ): expected result != 0, got 0."); 148 ck_assert_msg(res != 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::1} ): expected result != 0, got 0.");
149 149
150 ip2.ip6.uint8[15]++; 150 ip2.ip.v6.uint8[15]++;
151 res = ip_equal(&ip1, &ip2); 151 res = ip_equal(&ip1, &ip2);
152 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::2} ): expected result 0, got %u.", res); 152 ck_assert_msg(res == 0, "ip_equal( {TOX_AF_INET6, ::1}, {TOX_AF_INET6, ::2} ): expected result 0, got %u.", res);
153} 153}