summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-03 06:37:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-03 06:37:06 +0000
commit260d0d0399f902e9c079b3447d67957678c461c5 (patch)
tree602ba42a3463aff009a15abd9a347ebcbd87c1a0
parent4aec56ba712d8f91e7c8a14071267b635d534826 (diff)
add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/socket/test_socket.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index d933d9c0cc..d0f401b6f2 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -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)