mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e3c5fbba91
commit
3032bdb1d3
1 changed files with 27 additions and 23 deletions
|
@ -229,34 +229,38 @@ class TestSocket < Test::Unit::TestCase
|
||||||
begin
|
begin
|
||||||
ip_addrs = Socket.ip_address_list
|
ip_addrs = Socket.ip_address_list
|
||||||
rescue NotImplementedError
|
rescue NotImplementedError
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
sockets = Socket.udp_server_sockets(0)
|
Socket.udp_server_sockets(0) {|sockets|
|
||||||
port = sockets.first.local_address.ip_port
|
begin
|
||||||
|
port = sockets.first.local_address.ip_port
|
||||||
|
|
||||||
th = Thread.new {
|
th = Thread.new {
|
||||||
Socket.udp_server_loop_on(sockets) {|msg, msg_src|
|
Socket.udp_server_loop_on(sockets) {|msg, msg_src|
|
||||||
break if msg == "exit"
|
break if msg == "exit"
|
||||||
rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address])
|
rmsg = Marshal.dump([msg, msg_src.remote_address, msg_src.local_address])
|
||||||
msg_src.reply rmsg
|
msg_src.reply rmsg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_addrs.each {|ai|
|
ip_addrs.each {|ai|
|
||||||
Addrinfo.udp(ai.ip_address, port).connect {|s|
|
Addrinfo.udp(ai.ip_address, port).connect {|s|
|
||||||
msg1 = "<<<#{ai.inspect}>>>"
|
msg1 = "<<<#{ai.inspect}>>>"
|
||||||
s.sendmsg msg1
|
s.sendmsg msg1
|
||||||
msg2, addr = s.recvmsg
|
msg2, addr = s.recvmsg
|
||||||
msg2, remote_address, local_address = Marshal.load(msg2)
|
msg2, remote_address, local_address = Marshal.load(msg2)
|
||||||
assert_equal(msg1, msg2)
|
assert_equal(msg1, msg2)
|
||||||
assert_equal(ai.ip_address, addr.ip_address)
|
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
|
||||||
|
|
||||||
end if defined?(Socket)
|
end if defined?(Socket)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue