diff --git a/ChangeLog b/ChangeLog index 021cfdeb83..9ac327b9c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jun 26 12:08:51 2013 Tanaka Akira + + * test/socket/test_udp.rb: Close sockets explicitly. + Don't use fixed port number. + Wed Jun 26 07:27:17 2013 Tanaka Akira * bignum.c (bigand_int): Fix a buffer over read. 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)