diff --git a/spec/ruby/library/socket/tcpserver/accept_spec.rb b/spec/ruby/library/socket/tcpserver/accept_spec.rb index d38d95e0e19a..1039df3a1f83 100644 --- a/spec/ruby/library/socket/tcpserver/accept_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_spec.rb @@ -114,6 +114,17 @@ @socket = @server.accept @socket.should be_an_instance_of(TCPSocket) end + + it "returns a TCPSocket which is set to nonblocking" do + require 'io/nonblock' + @socket = @server.accept + @socket.should.nonblock? + end + + it "returns a TCPSocket which is set to close on exec" do + @socket = @server.accept + @socket.should.close_on_exec? + end end end end diff --git a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb index 3bec06c69746..e026bce134b4 100644 --- a/spec/ruby/library/socket/tcpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/initialize_spec.rb @@ -72,6 +72,17 @@ @client.remote_address.ip_port.should == @server.local_address.ip_port end + it "creates a socket which is set to nonblocking" do + require 'io/nonblock' + @client = TCPSocket.new(ip_address, @port) + @client.should.nonblock? + end + + it "creates a socket which is set to close on exec" do + @client = TCPSocket.new(ip_address, @port) + @client.should.close_on_exec? + end + describe 'using a local address and service' do it 'binds the client socket to the local address and service' do @client = TCPSocket.new(ip_address, @port, ip_address, 0) diff --git a/spec/ruby/library/socket/udpsocket/initialize_spec.rb b/spec/ruby/library/socket/udpsocket/initialize_spec.rb index 1d635149f7c4..cb84b5889939 100644 --- a/spec/ruby/library/socket/udpsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/udpsocket/initialize_spec.rb @@ -30,6 +30,17 @@ @socket.binmode?.should be_true end + it 'sets the socket to nonblock' do + require 'io/nonblock' + @socket = UDPSocket.new(:INET) + @socket.should.nonblock? + end + + it 'sets the socket to close on exec' do + @socket = UDPSocket.new(:INET) + @socket.should.close_on_exec? + end + it 'raises Errno::EAFNOSUPPORT or Errno::EPROTONOSUPPORT when given an invalid address family' do -> { UDPSocket.new(666) diff --git a/spec/ruby/library/socket/unixserver/accept_spec.rb b/spec/ruby/library/socket/unixserver/accept_spec.rb index 624782d6b98d..1305bc6220d3 100644 --- a/spec/ruby/library/socket/unixserver/accept_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_spec.rb @@ -110,6 +110,17 @@ @socket = @server.accept @socket.recv(5).should == 'hello' end + + it "is set to nonblocking" do + require 'io/nonblock' + @socket = @server.accept + @socket.should.nonblock? + end + + it "is set to close on exec" do + @socket = @server.accept + @socket.should.close_on_exec? + end end end end diff --git a/spec/ruby/library/socket/unixsocket/initialize_spec.rb b/spec/ruby/library/socket/unixsocket/initialize_spec.rb index 13b6972f0313..bf7896ab0eb5 100644 --- a/spec/ruby/library/socket/unixsocket/initialize_spec.rb +++ b/spec/ruby/library/socket/unixsocket/initialize_spec.rb @@ -33,6 +33,16 @@ it 'sets the socket to binmode' do @socket.binmode?.should be_true end + + it 'sets the socket to nonblock' do + require 'io/nonblock' + @socket.should.nonblock? + end + + it 'sets the socket to close on exec' do + @socket.should.close_on_exec? + end + end end end diff --git a/spec/tags/library/socket/tcpserver/accept_tags.txt b/spec/tags/library/socket/tcpserver/accept_tags.txt new file mode 100644 index 000000000000..abab2bc7a3e7 --- /dev/null +++ b/spec/tags/library/socket/tcpserver/accept_tags.txt @@ -0,0 +1,4 @@ +fails:TCPServer#accept using IPv4 with a connected client returns a TCPSocket which is set to nonblocking +fails:TCPServer#accept using IPv4 with a connected client returns a TCPSocket which is set to close on exec +fails:TCPServer#accept using IPv6 with a connected client returns a TCPSocket which is set to nonblocking +fails:TCPServer#accept using IPv6 with a connected client returns a TCPSocket which is set to close on exec diff --git a/spec/tags/library/socket/tcpsocket/initialize_tags.txt b/spec/tags/library/socket/tcpsocket/initialize_tags.txt index cf60a24babcf..c7071f6c86dc 100644 --- a/spec/tags/library/socket/tcpsocket/initialize_tags.txt +++ b/spec/tags/library/socket/tcpsocket/initialize_tags.txt @@ -2,3 +2,7 @@ fails:TCPSocket#initialize raises Errno::ETIMEDOUT with :connect_timeout when no fails:TCPSocket#initialize with a running server connects to a server when passed connect_timeout argument fails:TCPSocket#initialize raises IO::TimeoutError with :connect_timeout when no server is listening on the given address fails:TCPSocket#initialize with a running server does not use the given block and warns to use TCPSocket::open +fails:TCPSocket#initialize using IPv4 when a server is listening on the given address creates a socket which is set to nonblocking +fails:TCPSocket#initialize using IPv4 when a server is listening on the given address creates a socket which is set to close on exec +fails:TCPSocket#initialize using IPv6 when a server is listening on the given address creates a socket which is set to nonblocking +fails:TCPSocket#initialize using IPv6 when a server is listening on the given address creates a socket which is set to close on exec diff --git a/spec/tags/library/socket/udpsocket/initialize_tags.txt b/spec/tags/library/socket/udpsocket/initialize_tags.txt new file mode 100644 index 000000000000..f98bc6574593 --- /dev/null +++ b/spec/tags/library/socket/udpsocket/initialize_tags.txt @@ -0,0 +1,2 @@ +fails:UDPSocket#initialize sets the socket to nonblock +fails:UDPSocket#initialize sets the socket to close on exec diff --git a/spec/tags/library/socket/unixserver/accept_tags.txt b/spec/tags/library/socket/unixserver/accept_tags.txt new file mode 100644 index 000000000000..07cf2e516369 --- /dev/null +++ b/spec/tags/library/socket/unixserver/accept_tags.txt @@ -0,0 +1,2 @@ +fails:UNIXServer#accept with a client with data available the returned UNIXSocket is set to nonblocking +fails:UNIXServer#accept with a client with data available the returned UNIXSocket is set to close on exec diff --git a/spec/tags/library/socket/unixsocket/initialize_tags.txt b/spec/tags/library/socket/unixsocket/initialize_tags.txt new file mode 100644 index 000000000000..c679f66b1ec6 --- /dev/null +++ b/spec/tags/library/socket/unixsocket/initialize_tags.txt @@ -0,0 +1,2 @@ +fails:UNIXSocket#initialize using an existing socket path sets the socket to nonblock +fails:UNIXSocket#initialize using an existing socket path sets the socket to close on exec