mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
tests: support Linux kernels with CONFIG_IPV6=n
Detecting the presence of constants in C headers is insufficient, as a Linux kernel can be built with CONFIG_IPV6=n git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d7c806c079
commit
54ad3167e8
4 changed files with 29 additions and 21 deletions
|
@ -237,13 +237,15 @@ describe 'BasicSocket#setsockopt' do
|
||||||
@socket.getsockopt(:IP, :TTL).int.should == 255
|
@socket.getsockopt(:IP, :TTL).int.should == 255
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets an IPv6 boolean option' do
|
guard -> { SocketSpecs.ipv6_available? } do
|
||||||
socket = Socket.new(:INET6, :STREAM)
|
it 'sets an IPv6 boolean option' do
|
||||||
begin
|
socket = Socket.new(:INET6, :STREAM)
|
||||||
socket.setsockopt(:IPV6, :V6ONLY, true).should == 0
|
begin
|
||||||
socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
|
socket.setsockopt(:IPV6, :V6ONLY, true).should == 0
|
||||||
ensure
|
socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
|
||||||
socket.close
|
ensure
|
||||||
|
socket.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ module SocketSpecs
|
||||||
def self.ipv6_available?
|
def self.ipv6_available?
|
||||||
@ipv6_available ||= begin
|
@ipv6_available ||= begin
|
||||||
server = TCPServer.new('::1', 0)
|
server = TCPServer.new('::1', 0)
|
||||||
rescue Errno::EADDRNOTAVAIL, SocketError
|
rescue Errno::EAFNOSUPPORT, Errno::EADDRNOTAVAIL, SocketError
|
||||||
:no
|
:no
|
||||||
else
|
else
|
||||||
server.close
|
server.close
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
require_relative '../spec_helper'
|
require_relative '../spec_helper'
|
||||||
|
|
||||||
describe 'Socket#ipv6only!' do
|
guard -> { SocketSpecs.ipv6_available? } do
|
||||||
before do
|
describe 'Socket#ipv6only!' do
|
||||||
@socket = Socket.new(:INET6, :DGRAM)
|
before do
|
||||||
end
|
@socket = Socket.new(:INET6, :DGRAM)
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@socket.close
|
@socket.close
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enables IPv6 only mode' do
|
it 'enables IPv6 only mode' do
|
||||||
@socket.ipv6only!
|
@socket.ipv6only!
|
||||||
|
|
||||||
@socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
|
@socket.getsockopt(:IPV6, :V6ONLY).bool.should == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,9 +20,13 @@ class TestSocket_UDPSocket < Test::Unit::TestCase
|
||||||
assert_match(/AF_INET\b/, sock.inspect)
|
assert_match(/AF_INET\b/, sock.inspect)
|
||||||
}
|
}
|
||||||
if Socket.const_defined?(:AF_INET6)
|
if Socket.const_defined?(:AF_INET6)
|
||||||
UDPSocket.open(Socket::AF_INET6) {|sock|
|
begin
|
||||||
assert_match(/AF_INET6\b/, sock.inspect)
|
UDPSocket.open(Socket::AF_INET6) {|sock|
|
||||||
}
|
assert_match(/AF_INET6\b/, sock.inspect)
|
||||||
|
}
|
||||||
|
rescue Errno::EAFNOSUPPORT
|
||||||
|
skip 'AF_INET6 not supported by kernel'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue