diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-06-06 21:10:21 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-06-06 21:16:28 -0700 |
commit | 119ca4343cceed031f017ce2e0d2a1e709344a0f (patch) | |
tree | 0bb7ff9f03226ca3959ef039ae72cb86c6f329fe /spec/ruby/library | |
parent | c55de95ff1c4ea6313c2863037703a0e5f0d0f4f (diff) |
Make specs pass on OpenBSD
Skip Process clockres specs that don't work on either FreeBSD or
Solaris/AIX in addition to OpenBSD.
Run most current String#crypt specs on non-OpenBSD, and add a new
set of crypt specs for OpenBSD, which support bcrypt but not DES
in crypt(3).
Use @server.connect_address instead of @server.getsockname in some
socket tests, as OpenBSD does not treat connection to all zero
IPv4 or IPv6 addresses as connection to localhost.
When trying to connect using UDP on an unsupported address family,
allow Errno::EPROTONOSUPPORT in addition to Errno::EAFNOSUPPORT,
as OpenBSD raises the former.
Diffstat (limited to 'spec/ruby/library')
-rw-r--r-- | spec/ruby/library/socket/socket/connect_nonblock_spec.rb | 12 | ||||
-rw-r--r-- | spec/ruby/library/socket/udpsocket/initialize_spec.rb | 10 |
2 files changed, 14 insertions, 8 deletions
diff --git a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb index c56bebee62..b5f416d96f 100644 --- a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb @@ -114,24 +114,24 @@ describe 'Socket#connect_nonblock' do platform_is_not :windows do it 'raises Errno::EISCONN when already connected' do @server.listen(1) - @client.connect(@server.getsockname).should == 0 + @client.connect(@server.connect_address).should == 0 lambda { - @client.connect_nonblock(@server.getsockname) + @client.connect_nonblock(@server.connect_address) # A second call needed if non-blocking sockets become default # XXX honestly I don't expect any real code to care about this spec # as it's too implementation-dependent and checking for connect() # errors is futile anyways because of TOCTOU - @client.connect_nonblock(@server.getsockname) + @client.connect_nonblock(@server.connect_address) }.should raise_error(Errno::EISCONN) end it 'returns 0 when already connected in exceptionless mode' do @server.listen(1) - @client.connect(@server.getsockname).should == 0 + @client.connect(@server.connect_address).should == 0 - @client.connect_nonblock(@server.getsockname, exception: false).should == 0 + @client.connect_nonblock(@server.connect_address, exception: false).should == 0 end end @@ -140,7 +140,7 @@ describe 'Socket#connect_nonblock' do @server.bind(@sockaddr) lambda { - @client.connect_nonblock(@server.getsockname) + @client.connect_nonblock(@server.connect_address) }.should raise_error(IO::EINPROGRESSWaitWritable) end end diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb index 06f7b5ef1c..9497d0dcbc 100644 --- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/udpsocket/initialize_spec.rb @@ -30,7 +30,13 @@ describe 'UDPSocket#initialize' do @socket.binmode?.should be_true end - it 'raises Errno::EAFNOSUPPORT when given an invalid address family' do - lambda { UDPSocket.new(666) }.should raise_error(Errno::EAFNOSUPPORT) + it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT when given an invalid address family' do + begin + UDPSocket.new(666) + rescue Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT => e + [Errno::EAFNOSUPPORT, Errno::EPROTONOSUPPORT].should include(e.class) + else + raise "expected Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT exception raised" + end end end |