summaryrefslogtreecommitdiff
path: root/test/socket
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 03:09:54 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 03:09:54 +0000
commit3a8100835485c64f97e10a3cd1624a1b33145326 (patch)
tree617026ed9dd0ad61f4cbff7b0cf039a9092ff50f /test/socket
parent3ade5353e1f7a8893443ade7182851edac891295 (diff)
* test/socket/test_udp.rb: Close sockets explicitly.
Don't use fixed port number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r--test/socket/test_udp.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/socket/test_udp.rb b/test/socket/test_udp.rb
index e75d2c7..b07a4b7 100644
--- a/test/socket/test_udp.rb
+++ b/test/socket/test_udp.rb
@@ -35,14 +35,16 @@ class TestSocket_UDPSocket < Test::Unit::TestCase
assert_raise(IOError, "[ruby-dev:25057]") {
s.bind(host, 2000)
}
+ ensure
+ s.close if s && !s.closed?
end
def test_bind_addrinuse
host = "127.0.0.1"
- port = 2001
in_use = UDPSocket.new
- in_use.bind(host, port)
+ in_use.bind(host, 0)
+ port = in_use.addr[1]
s = UDPSocket.new
@@ -51,6 +53,9 @@ class TestSocket_UDPSocket < Test::Unit::TestCase
end
assert_match "bind(2) for \"#{host}\" port #{port}", e.message
+ ensure
+ in_use.close if in_use
+ s.close if s
end
def test_send_too_long
@@ -61,5 +66,7 @@ class TestSocket_UDPSocket < Test::Unit::TestCase
end
assert_match 'for "127.0.0.1" port 7', e.message
+ ensure
+ u.close if u
end
end if defined?(UDPSocket)