diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-11 15:29:35 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-11 15:29:35 +0000 |
| commit | d4a79d4c3030dc43d607980c527345491d5d5624 (patch) | |
| tree | 903b365ccff0ff985ff0cb0b987a6a826ea17484 | |
| parent | 9d517a703d71ab3bce6b68545788f663a087efc6 (diff) | |
| download | ruby-d4a79d4c3030dc43d607980c527345491d5d5624.tar.gz ruby-d4a79d4c3030dc43d607980c527345491d5d5624.tar.xz ruby-d4a79d4c3030dc43d607980c527345491d5d5624.zip | |
test updated.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | test/socket/test_socket.rb | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index 5b2b7b41d..d69b7795d 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -229,34 +229,38 @@ class TestSocket < Test::Unit::TestCase begin ip_addrs = Socket.ip_address_list rescue NotImplementedError + return end - sockets = Socket.udp_server_sockets(0) - port = sockets.first.local_address.ip_port + Socket.udp_server_sockets(0) {|sockets| + begin + port = sockets.first.local_address.ip_port - th = Thread.new { - Socket.udp_server_loop_on(sockets) {|msg, msg_src| - break if msg == "exit" - rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address]) - msg_src.reply rmsg - } - } + th = Thread.new { + Socket.udp_server_loop_on(sockets) {|msg, msg_src| + break if msg == "exit" + rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address]) + msg_src.reply rmsg + } + } - ip_addrs.each {|ai| - Addrinfo.udp(ai.ip_address, port).connect {|s| - msg1 = "<<<#{ai.inspect}>>>" - s.sendmsg msg1 - msg2, addr = s.recvmsg - msg2, remote_address, local_address = Marshal.load(msg2) - assert_equal(msg1, msg2) - assert_equal(ai.ip_address, addr.ip_address) - } + ip_addrs.each {|ai| + Addrinfo.udp(ai.ip_address, port).connect {|s| + msg1 = "<<<#{ai.inspect}>>>" + s.sendmsg msg1 + msg2, addr = s.recvmsg + msg2, remote_address, local_address = Marshal.load(msg2) + assert_equal(msg1, msg2) + assert_equal(ai.ip_address, addr.ip_address) + } + } + ensure + if th + Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" } + th.join + end + end } - ensure - if th - Addrinfo.udp("127.0.0.1", port).connect {|s| s.sendmsg "exit" } - th.join - end end end if defined?(Socket) |
