mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4aec56ba71
commit
260d0d0399
1 changed files with 26 additions and 0 deletions
|
@ -143,6 +143,32 @@ class TestSocket < Test::Unit::TestCase
|
|||
}
|
||||
}
|
||||
end
|
||||
|
||||
def test_accept_loop
|
||||
Dir.mktmpdir {|tmpdir|
|
||||
tcp_servers = []
|
||||
clients = []
|
||||
accepted = []
|
||||
begin
|
||||
tcp_servers = Socket.tcp_server_sockets(0)
|
||||
unix_server = Socket.unix_server_socket("#{tmpdir}/sock")
|
||||
tcp_servers.each {|s|
|
||||
clients << s.local_address.connect
|
||||
}
|
||||
clients << unix_server.local_address.connect
|
||||
Socket.accept_loop(tcp_servers, unix_server) {|s|
|
||||
accepted << s
|
||||
break if clients.length == accepted.length
|
||||
}
|
||||
assert_equal(clients.length, accepted.length)
|
||||
ensure
|
||||
tcp_servers.each {|s| s.close if !s.closed? }
|
||||
unix_server.close if !unix_server.closed?
|
||||
clients.each {|s| s.close if !s.closed? }
|
||||
accepted.each {|s| s.close if !s.closed? }
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end if defined?(Socket)
|
||||
|
|
Loading…
Reference in a new issue