mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
spec/ruby/library/socket/*: more FreeBSD fixes
FreeBSD portability notes: Loopback connections are not instantaneous (unlike Linux), so non-blocking read-after-write MUST check for readability via IO.select or IO#wait_readable before attempting non-blocking recv/read operations. IPv6 seems favored, so we'll get "::" instead of "0.0.0.0" Some constants are different or obsolete, so that should be self-explanatory. There are still other failures I or somebody else needs to get to when we have time and feel like dealing with spec DSL: http://rubyci.s3.amazonaws.com/freebsd11zfs/ruby-trunk/recent.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
52102f6ff5
commit
ab8791d7d2
7 changed files with 33 additions and 5 deletions
|
@ -156,6 +156,7 @@ describe 'BasicSocket#recvmsg_nonblock' do
|
|||
|
||||
describe 'the returned Array' do
|
||||
before do
|
||||
platform_is(:freebsd) { IO.select([@socket]) }
|
||||
@array = @socket.recvmsg_nonblock
|
||||
end
|
||||
|
||||
|
|
|
@ -89,11 +89,22 @@ describe "Socket::Constants" do
|
|||
|
||||
platform_is_not :windows do
|
||||
it 'defines SCM options' do
|
||||
platform_is :freebsd do
|
||||
Socket::Constants.should have_constant('SCM_CREDS')
|
||||
end
|
||||
platform_is_not :freebsd do
|
||||
Socket::Constants.should have_constant('SCM_CREDENTIALS')
|
||||
end
|
||||
end
|
||||
|
||||
it 'defines error options' do
|
||||
consts = ["EAI_ADDRFAMILY", "EAI_NODATA"]
|
||||
|
||||
# FreeBSD (11.1, at least) obsoletes EAI_ADDRFAMILY and EAI_NODATA
|
||||
platform_is :freebsd do
|
||||
consts = %w(EAI_MEMORY)
|
||||
end
|
||||
|
||||
consts.each do |c|
|
||||
Socket::Constants.should have_constant(c)
|
||||
end
|
||||
|
|
|
@ -86,6 +86,8 @@ describe 'Socket#accept_nonblock' do
|
|||
@client = Socket.new(family, :STREAM, 0)
|
||||
|
||||
@client.connect(addr)
|
||||
|
||||
platform_is(:freebsd) { IO.select([@server]) }
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
|
@ -36,6 +36,8 @@ describe 'Socket#recvfrom_nonblock' do
|
|||
describe 'with data available' do
|
||||
before do
|
||||
@client.write('hello')
|
||||
|
||||
platform_is(:freebsd) { IO.select([@server]) }
|
||||
end
|
||||
|
||||
platform_is_not :windows do
|
||||
|
@ -52,6 +54,8 @@ describe 'Socket#recvfrom_nonblock' do
|
|||
5.times do
|
||||
@client.write('hello')
|
||||
|
||||
platform_is(:freebsd) { IO.select([@server]) }
|
||||
|
||||
msg, _ = @server.recvfrom_nonblock(5)
|
||||
|
||||
msg.should == 'hello'
|
||||
|
|
|
@ -20,6 +20,12 @@ describe 'Socket.udp_server_recv' do
|
|||
|
||||
@client.write('hello')
|
||||
|
||||
# FreeBSD sockets are not instanteous over loopback and
|
||||
# will EAGAIN on recv.
|
||||
platform_is :freebsd do
|
||||
IO.select([@server])
|
||||
end
|
||||
|
||||
Socket.udp_server_recv([@server]) do |message, source|
|
||||
msg = message
|
||||
src = source
|
||||
|
|
|
@ -17,8 +17,9 @@ describe 'TCPServer#initialize' do
|
|||
end
|
||||
|
||||
platform_is_not :windows do
|
||||
it 'sets the hostname to 0.0.0.0' do
|
||||
@server.local_address.ip_address.should == '0.0.0.0'
|
||||
it 'sets the hostname to 0.0.0.0 or ::' do
|
||||
a = @server.local_address
|
||||
a.ip_address.should == (a.ipv6? ? '::' : '0.0.0.0')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,8 +43,9 @@ describe 'TCPServer#initialize' do
|
|||
end
|
||||
|
||||
platform_is_not :windows do
|
||||
it 'sets the hostname to 0.0.0.0' do
|
||||
@server.local_address.ip_address.should == '0.0.0.0'
|
||||
it 'sets the hostname to 0.0.0.0 or ::' do
|
||||
a = @server.local_address
|
||||
a.ip_address.should == (a.ipv6? ? '::' : '0.0.0.0')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,8 @@ describe 'UDPSocket#recvfrom_nonblock' do
|
|||
describe 'with data available' do
|
||||
before do
|
||||
@client.write('hello')
|
||||
|
||||
platform_is(:freebsd) { IO.select([@server]) }
|
||||
end
|
||||
|
||||
it 'returns an Array containing the data and an Array' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue