mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
[ruby/fiddle] Use test-unit gem (https://github.com/ruby/fiddle/pull/69)
e08c4c635e
Co-authored-by: Sutou Kouhei <kou@clear-code.com>
This commit is contained in:
parent
afa33da72b
commit
8f752c95d2
Notes:
git
2021-09-05 19:26:21 +09:00
8 changed files with 79 additions and 37 deletions
|
@ -179,16 +179,6 @@ module Fiddle
|
|||
end
|
||||
|
||||
def test_free=
|
||||
assert_normal_exit(<<-"End", '[ruby-dev:39269]')
|
||||
require 'fiddle'
|
||||
include Fiddle
|
||||
free = Fiddle::Function.new(Fiddle::RUBY_FREE, [TYPE_VOIDP], TYPE_VOID)
|
||||
ptr = Fiddle::Pointer.malloc(4)
|
||||
ptr.free = free
|
||||
free.ptr
|
||||
ptr.free.ptr
|
||||
End
|
||||
|
||||
free = Function.new(Fiddle::RUBY_FREE, [TYPE_VOIDP], TYPE_VOID)
|
||||
ptr = Pointer.malloc(4)
|
||||
ptr.free = free
|
||||
|
@ -282,7 +272,16 @@ module Fiddle
|
|||
end
|
||||
|
||||
def test_no_memory_leak
|
||||
assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Pointer.allocate}', rss: true)
|
||||
if respond_to?(:assert_nothing_leaked_memory)
|
||||
n_tries = 100_000
|
||||
assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do
|
||||
n_tries.times do
|
||||
Fiddle::Pointer.allocate
|
||||
end
|
||||
end
|
||||
else
|
||||
assert_no_memory_leak(%w[-W0 -rfiddle.so], '', '100_000.times {Fiddle::Pointer.allocate}', rss: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end if defined?(Fiddle)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue