ruby-changes:33220
From: nobu <ko1@a...>
Date: Sun, 9 Mar 2014 13:19:14 +0900 (JST)
Subject: [ruby-changes:33220] nobu:r45299 (trunk): tests for [Bug #9599]
nobu 2014-03-09 13:19:10 +0900 (Sun, 09 Mar 2014) New Revision: 45299 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45299 Log: tests for [Bug #9599] * test/dl/test_{cptr,handle}.rb: tests for [Bug #9599]. * test/fiddle/test_{handle,pointer}.rb: ditto. Modified files: trunk/test/dl/test_cptr.rb trunk/test/dl/test_handle.rb trunk/test/fiddle/test_handle.rb trunk/test/fiddle/test_pointer.rb Index: test/fiddle/test_pointer.rb =================================================================== --- test/fiddle/test_pointer.rb (revision 45298) +++ test/fiddle/test_pointer.rb (revision 45299) @@ -230,5 +230,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_pointer.rb#L230 assert_raise(DLError) {nullpo[0]} assert_raise(DLError) {nullpo[0] = 1} end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Pointer.allocate}', limit: 1.2) + end end end if defined?(Fiddle) Index: test/fiddle/test_handle.rb =================================================================== --- test/fiddle/test_handle.rb (revision 45298) +++ test/fiddle/test_handle.rb (revision 45299) @@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_handle.rb#L1 begin require_relative 'helper' + require_relative '../ruby/envutil' rescue LoadError end @@ -7,6 +8,8 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_handle.rb#L8 class TestHandle < TestCase include Fiddle + include Test::Unit::Assertions + def test_to_i handle = Fiddle::Handle.new(LIBC_SO) assert_kind_of Integer, handle.to_i @@ -185,5 +188,9 @@ module Fiddle https://github.com/ruby/ruby/blob/trunk/test/fiddle/test_handle.rb#L188 Socket.gethostbyname("localhost") Fiddle.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Handle.allocate}; GC.start', limit: 1.2) + end end end if defined?(Fiddle) Index: test/dl/test_cptr.rb =================================================================== --- test/dl/test_cptr.rb (revision 45298) +++ test/dl/test_cptr.rb (revision 45299) @@ -219,4 +219,8 @@ module DL https://github.com/ruby/ruby/blob/trunk/test/dl/test_cptr.rb#L219 assert_raise(DLError) {nullpo[0] = 1} end end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::CPtr.allocate}', limit: 1.2) + end end Index: test/dl/test_handle.rb =================================================================== --- test/dl/test_handle.rb (revision 45298) +++ test/dl/test_handle.rb (revision 45299) @@ -184,4 +184,8 @@ module DL https://github.com/ruby/ruby/blob/trunk/test/dl/test_handle.rb#L184 DL.dlopen("/lib/libc.so.7").sym('strcpy') end if /freebsd/=~ RUBY_PLATFORM end + + def test_no_memory_leak + assert_no_memory_leak(%w[-W0 -rdl.so], '', '100_000.times {DL::Handle.allocate}; GC.start', limit: 1.2) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/