Fix udp multicast test when no exernal interfaces are available
Fixes
@@ -179,7 +179,7 @@ return require('lib/tap')(function (test)
assert(uv.udp_bind(server, bind_addr, TEST_PORT))
local _, err, errname = uv.udp_set_membership(server, multicast_addr, interface_addr, "join")
if errname == "ENODEV" then
- print("no ipv6 multicast route, skipping")
+ print("no multicast route, skipping")
server:close()
return
elseif errname == "EADDRNOTAVAIL" and multicast_addr == "ff02::1" then
@@ -240,14 +240,18 @@ return require('lib/tap')(function (test)
end
end
- test("udp multicast join ipv4", multicast_join_test("0.0.0.0", "239.255.0.1", nil))
-
- test("udp multicast join ipv6", function(print, p, expect, uv)
- local function can_ipv6_external()
+ -- TODO This might be overkill, but the multicast
+ -- tests seem to rely on external interfaces being
+ -- available on some platforms. So, we use this to skip
+ -- the tests when there are no relevant exernal interfaces
+ -- available. Note: The Libuv multicast join test does use this
+ -- same check for skipping the ipv6 test; we just expanded it to
+ -- the ipv4 test as well.
+ local function has_external_interface(uv, family)
local addresses = assert(uv.interface_addresses())
for _, vals in pairs(addresses) do
for _, info in ipairs(vals) do
- if info.family == "inet6" and not info.internal then
+ if (not family or info.family == family) and not info.internal then
return true
end
end
@@ -255,11 +259,20 @@ return require('lib/tap')(function (test)
return false
end
- if not can_ipv6_external() then
- print("no ipv6 support, skipping")
+ test("udp multicast join ipv4", function(print, p, expect, uv)
+ if not has_external_interface(uv, "inet") then
+ print("no external ipv4 interface, skipping")
return
end
+ local testfn = multicast_join_test("0.0.0.0", "239.255.0.1", nil)
+ return testfn(print, p, expect, uv)
+ end)
+ test("udp multicast join ipv6", function(print, p, expect, uv)
+ if not has_external_interface(uv, "inet6") then
+ print("no external ipv6 interface, skipping")
+ return
+ end
local testfn = multicast_join_test("::", "ff02::1", nil)
return testfn(print, p, expect, uv)
end)
