summaryrefslogtreecommitdiff
path: root/test/rinda
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-22 02:00:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-22 02:00:02 +0000
commitc83f23ad52f318a69bf6886f54dd6185cd8725ab (patch)
tree3b4aa7276d4becadc02fca8f67a1aab815b66049 /test/rinda
parentb7458f20ffeb9cd0cd2514d86ecd9b25b4f2cb9b (diff)
test_rinda.rb: ipv6_mc
* test/rinda/test_rinda.rb (RingIPv6#ipv6_mc): extract IPv6 multicast setup and cleanup, and ignore ENETDOWN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rinda')
-rw-r--r--test/rinda/test_rinda.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index a07eac427c4..aae1a1d7a46 100644
--- a/test/rinda/test_rinda.rb
+++ b/test/rinda/test_rinda.rb
@@ -552,6 +552,26 @@ module RingIPv6
end
skip 'IPv6 not available'
end
+
+ def ipv6_mc(rf, hops = nil)
+ ifaddr = prepare_ipv6(rf)
+ rf.multicast_hops = hops if hops
+ begin
+ v6mc = rf.make_socket("ff02::1")
+ rescue Errno::EINVAL
+ # somehow Debian 6.0.7 needs ifname
+ v6mc = rf.make_socket("ff02::1%#{ifaddr.name}")
+ rescue Errno::EADDRNOTAVAIL
+ return # IPv6 address for multicast not available
+ rescue Errno::ENETDOWN
+ return # Network is down
+ end
+ begin
+ yield v6mc
+ ensure
+ v6mc.close
+ end
+ end
end
class TestRingServer < Test::Unit::TestCase
@@ -788,20 +808,10 @@ class TestRingFinger < Test::Unit::TestCase
end
def test_make_socket_ipv6_multicast
- ifaddr = prepare_ipv6(@rf)
- begin
- v6mc = @rf.make_socket("ff02::1")
- rescue Errno::EINVAL
- # somehow Debian 6.0.7 needs ifname
- v6mc = @rf.make_socket("ff02::1%#{ifaddr.name}")
- rescue Errno::EADDRNOTAVAIL
- return # IPv6 address for multicast not available
+ ipv6_mc(@rf) do |v6mc|
+ assert_equal(1, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_LOOP).int)
+ assert_equal(1, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS).int)
end
-
- assert_equal(1, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_LOOP).int)
- assert_equal(1, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS).int)
- ensure
- v6mc.close if v6mc
end
def test_make_socket_ipv4_multicast_hops
@@ -813,19 +823,9 @@ class TestRingFinger < Test::Unit::TestCase
end
def test_make_socket_ipv6_multicast_hops
- ifaddr = prepare_ipv6(@rf)
- @rf.multicast_hops = 2
- begin
- v6mc = @rf.make_socket("ff02::1")
- rescue Errno::EINVAL
- # somehow Debian 6.0.7 needs ifname
- v6mc = @rf.make_socket("ff02::1%#{ifaddr.name}")
- rescue Errno::EADDRNOTAVAIL
- return # IPv6 address for multicast not available
+ ipv6_mc(@rf, 2) do |v6mc|
+ assert_equal(2, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS).int)
end
- assert_equal(2, v6mc.getsockopt(:IPPROTO_IPV6, :IPV6_MULTICAST_HOPS).int)
- ensure
- v6mc.close if v6mc
end
end