summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-07 06:44:24 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-06-07 06:44:24 +0000
commitaf19c6657066c18a739ee08eadadbc522d9bbcbb (patch)
tree6c13644379c4e1467d5876f0e62ca3589c0df27f /test
parent301f4076f8c5763489edf26133d546f80377f9cc (diff)
downloadruby-af19c6657066c18a739ee08eadadbc522d9bbcbb.tar.gz
* test/socket/{test_nonblock.rb, test_socket.rb}: Windows support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/socket/test_nonblock.rb26
-rw-r--r--test/socket/test_socket.rb2
2 files changed, 14 insertions, 14 deletions
diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb
index c861120912..33123fbcc0 100644
--- a/test/socket/test_nonblock.rb
+++ b/test/socket/test_nonblock.rb
@@ -11,7 +11,7 @@ class TestNonblockSocket < Test::Unit::TestCase
serv = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
serv.bind(Socket.sockaddr_in(0, "127.0.0.1"))
serv.listen(5)
- assert_raise(Errno::EAGAIN) { serv.accept_nonblock }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { serv.accept_nonblock }
c = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
c.connect(serv.getsockname)
s, sockaddr = serv.accept_nonblock
@@ -51,8 +51,8 @@ class TestNonblockSocket < Test::Unit::TestCase
u1 = UDPSocket.new
u2 = UDPSocket.new
u1.bind("127.0.0.1", 0)
- assert_raise(Errno::EAGAIN) { u1.recvfrom_nonblock(100) }
- assert_raise(Errno::EAGAIN) { u2.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { u1.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINVAL) { u2.recvfrom_nonblock(100) }
u2.send("aaa", 0, u1.getsockname)
IO.select [u1]
mesg, inet_addr = u1.recvfrom_nonblock(100)
@@ -61,7 +61,7 @@ class TestNonblockSocket < Test::Unit::TestCase
af, port, host, addr = inet_addr
u2_port, u2_addr = Socket.unpack_sockaddr_in(u2.getsockname)
assert_equal(u2_port, port)
- assert_raise(Errno::EAGAIN) { u1.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { u1.recvfrom_nonblock(100) }
u2.send("", 0, u1.getsockname)
IO.select [u1]
mesg, inet_addr = u1.recvfrom_nonblock(100)
@@ -82,8 +82,8 @@ class TestNonblockSocket < Test::Unit::TestCase
serv, serv_path = bound_unix_socket(UNIXServer)
c = UNIXSocket.new(serv_path)
s = serv.accept
- assert_raise(Errno::EAGAIN) { s.recvfrom_nonblock(100) }
- assert_raise(Errno::EAGAIN) { c.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { s.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { c.recvfrom_nonblock(100) }
s.write "aaa"
IO.select [c]
mesg, unix_addr = c.recvfrom_nonblock(100)
@@ -102,14 +102,14 @@ class TestNonblockSocket < Test::Unit::TestCase
serv.close if serv
c.close if c
s.close if s && !s.closed?
- end
+ end if defined?(UNIXSocket)
def test_socket_recvfrom_nonblock
s1 = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
s1.bind(Socket.sockaddr_in(0, "127.0.0.1"))
s2 = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
- assert_raise(Errno::EAGAIN) { s1.recvfrom_nonblock(100) }
- assert_raise(Errno::EAGAIN) { s2.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { s1.recvfrom_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK, Errno::EINVAL) { s2.recvfrom_nonblock(100) }
s2.send("aaa", 0, s1.getsockname)
IO.select [s1]
mesg, sockaddr = s1.recvfrom_nonblock(100)
@@ -134,13 +134,13 @@ class TestNonblockSocket < Test::Unit::TestCase
def test_read_nonblock
c, s = tcp_pair
- assert_raise(Errno::EAGAIN) { c.read_nonblock(100) }
- assert_raise(Errno::EAGAIN) { s.read_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { c.read_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { s.read_nonblock(100) }
c.write("abc")
IO.select [s]
assert_equal("a", s.read_nonblock(1))
assert_equal("bc", s.read_nonblock(100))
- assert_raise(Errno::EAGAIN) { s.read_nonblock(100) }
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) { s.read_nonblock(100) }
ensure
c.close if c
s.close if s
@@ -154,7 +154,7 @@ class TestNonblockSocket < Test::Unit::TestCase
ret = c.write_nonblock(str)
assert_operator(ret, :>, 0)
loop {
- assert_raise(Errno::EAGAIN) {
+ assert_raise(Errno::EAGAIN, Errno::EWOULDBLOCK) {
loop {
ret = c.write_nonblock(str)
assert_operator(ret, :>, 0)
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 4eab094e7c..6b4805bbd0 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -80,4 +80,4 @@ class TestSocket < Test::Unit::TestCase
sockaddr_un = Socket.sockaddr_un("/tmp/s")
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
end
-end
+end if defined?(Socket) && Socket.respond_to?(:sockaddr_un)