summaryrefslogtreecommitdiff
path: root/deps/uv/test/test-ip6-addr.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test/test-ip6-addr.c')
-rw-r--r--deps/uv/test/test-ip6-addr.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/deps/uv/test/test-ip6-addr.c b/deps/uv/test/test-ip6-addr.c
index 156fccde39..25570dcacd 100644
--- a/deps/uv/test/test-ip6-addr.c
+++ b/deps/uv/test/test-ip6-addr.c
@@ -44,8 +44,12 @@ TEST_IMPL(ip6_addr_link_local) {
const char* device_name;
/* 40 bytes address, 16 bytes device name, plus reserve. */
char scoped_addr[128];
+ size_t scoped_addr_len;
+ char interface_id[UV_IF_NAMESIZE];
+ size_t interface_id_len;
int count;
int ix;
+ int r;
ASSERT(0 == uv_interface_addresses(&addresses, &count));
@@ -67,19 +71,29 @@ TEST_IMPL(ip6_addr_link_local) {
iface_index = address->address.address6.sin6_scope_id;
device_name = address->name;
+ scoped_addr_len = sizeof(scoped_addr);
+ ASSERT(0 == uv_if_indextoname(iface_index, scoped_addr, &scoped_addr_len));
+#ifndef _WIN32
+ /* This assert fails on Windows, as Windows semantics are different. */
+ ASSERT(0 == strcmp(device_name, scoped_addr));
+#endif
+
+ interface_id_len = sizeof(interface_id);
+ r = uv_if_indextoiid(iface_index, interface_id, &interface_id_len);
+ ASSERT(0 == r);
#ifdef _WIN32
- snprintf(scoped_addr,
- sizeof(scoped_addr),
- "%s%%%d",
- string_address,
- iface_index);
+ /* On Windows, the interface identifier is the numeric string of the index. */
+ ASSERT(strtol(interface_id, NULL, 10) == iface_index);
#else
+ /* On Unix/Linux, the interface identifier is the interface device name. */
+ ASSERT(0 == strcmp(device_name, interface_id));
+#endif
+
snprintf(scoped_addr,
sizeof(scoped_addr),
"%s%%%s",
string_address,
- device_name);
-#endif
+ interface_id);
fprintf(stderr, "Testing link-local address %s "
"(iface_index: 0x%02x, device_name: %s)\n",
@@ -96,6 +110,9 @@ TEST_IMPL(ip6_addr_link_local) {
uv_free_interface_addresses(addresses, count);
+ scoped_addr_len = sizeof(scoped_addr);
+ ASSERT(0 != uv_if_indextoname((unsigned int)-1, scoped_addr, &scoped_addr_len));
+
MAKE_VALGRIND_HAPPY();
return 0;
}