mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
tests for [Bug #9599]
* test/dl/test_{cptr,handle}.rb: tests for [Bug #9599]. * test/fiddle/test_{handle,pointer}.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e20cd8ee49
commit
cb05f199ee
4 changed files with 19 additions and 0 deletions
|
@ -219,4 +219,8 @@ module DL
|
||||||
assert_raise(DLError) {nullpo[0] = 1}
|
assert_raise(DLError) {nullpo[0] = 1}
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -184,4 +184,8 @@ module DL
|
||||||
DL.dlopen("/lib/libc.so.7").sym('strcpy')
|
DL.dlopen("/lib/libc.so.7").sym('strcpy')
|
||||||
end if /freebsd/=~ RUBY_PLATFORM
|
end if /freebsd/=~ RUBY_PLATFORM
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
begin
|
begin
|
||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
require_relative '../ruby/envutil'
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,6 +8,8 @@ module Fiddle
|
||||||
class TestHandle < TestCase
|
class TestHandle < TestCase
|
||||||
include Fiddle
|
include Fiddle
|
||||||
|
|
||||||
|
include Test::Unit::Assertions
|
||||||
|
|
||||||
def test_to_i
|
def test_to_i
|
||||||
handle = Fiddle::Handle.new(LIBC_SO)
|
handle = Fiddle::Handle.new(LIBC_SO)
|
||||||
assert_kind_of Integer, handle.to_i
|
assert_kind_of Integer, handle.to_i
|
||||||
|
@ -185,5 +188,9 @@ module Fiddle
|
||||||
Socket.gethostbyname("localhost")
|
Socket.gethostbyname("localhost")
|
||||||
Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
|
Fiddle.dlopen("/lib/libc.so.7").sym('strcpy')
|
||||||
end if /freebsd/=~ RUBY_PLATFORM
|
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
|
||||||
end if defined?(Fiddle)
|
end if defined?(Fiddle)
|
||||||
|
|
|
@ -230,5 +230,9 @@ module Fiddle
|
||||||
assert_raise(DLError) {nullpo[0]}
|
assert_raise(DLError) {nullpo[0]}
|
||||||
assert_raise(DLError) {nullpo[0] = 1}
|
assert_raise(DLError) {nullpo[0] = 1}
|
||||||
end
|
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
|
||||||
end if defined?(Fiddle)
|
end if defined?(Fiddle)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue