summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-19 08:53:11 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-19 08:53:11 +0000
commit666049981f1bb5a886a7ae837f800946f0192adb (patch)
treec8f91c9bcdd129dd98fe1e7fec0aa3de6bfa7d8f /test/socket
parent2737b90e36f43865be74ebf6b71ea3ab42309720 (diff)
Use UDP for sendmsg/recvmsg tests.
sendmsg/recvmsg doesn't work with SOCK_STREAM on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_nonblock.rb36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb
index f29766886f..59ff1522bc 100644
--- a/test/socket/test_nonblock.rb
+++ b/test/socket/test_nonblock.rb
@@ -138,6 +138,30 @@ class TestSocketNonblock < Test::Unit::TestCase
serv.close if serv && !serv.closed?
end
+ def udp_pair
+ s1 = UDPSocket.new
+ s1.bind('127.0.0.1', 0)
+ af, port1, host, addr1 = s1.addr
+
+ s2 = UDPSocket.new
+ s2.bind('127.0.0.1', 0)
+ af, port2, host, addr2 = s2.addr
+
+ s1.connect(addr2, port2)
+ s2.connect(addr1, port1)
+
+ if block_given?
+ begin
+ yield s1, s2
+ ensure
+ s1.close if !s1.closed?
+ s2.close if !s2.closed?
+ end
+ else
+ return s1, s2
+ end
+ end
+
def test_tcp_recv_nonblock
c, s = tcp_pair
assert_raise(IO::WaitReadable) { c.recv_nonblock(100) }
@@ -191,13 +215,15 @@ class TestSocketNonblock < Test::Unit::TestCase
=end
def test_sendmsg_nonblock_error
- tcp_pair {|c, s|
+ udp_pair {|s1, s2|
begin
loop {
- c.sendmsg_nonblock("a" * 100000)
+ s1.sendmsg_nonblock("a" * 100000)
}
rescue NotImplementedError
skip "sendmsg not implemented on this platform."
+ rescue Errno::EMSGSIZE
+ # UDP has 64K limit (if no Jumbograms). No problem.
rescue Errno::EWOULDBLOCK
assert_kind_of(IO::WaitWritable, $!)
end
@@ -205,11 +231,11 @@ class TestSocketNonblock < Test::Unit::TestCase
end
def test_recvmsg_nonblock_error
- tcp_pair {|c, s|
+ udp_pair {|s1, s2|
begin
- c.recvmsg_nonblock(4096)
+ s1.recvmsg_nonblock(4096)
rescue NotImplementedError
- skip "sendmsg not implemented on this platform."
+ skip "recvmsg not implemented on this platform."
rescue Errno::EWOULDBLOCK
assert_kind_of(IO::WaitReadable, $!)
end