From 3a8100835485c64f97e10a3cd1624a1b33145326 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 26 Jun 2013 03:09:54 +0000 Subject: * 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 --- test/socket/test_udp.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/socket') diff --git a/test/socket/test_udp.rb b/test/socket/test_udp.rb index e75d2c7881..b07a4b73b3 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) -- cgit v1.2.3