diff options
Diffstat (limited to 'test/fiddle/test_handle.rb')
-rw-r--r-- | test/fiddle/test_handle.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/fiddle/test_handle.rb b/test/fiddle/test_handle.rb index 7e3ff9d844..412c10e09d 100644 --- a/test/fiddle/test_handle.rb +++ b/test/fiddle/test_handle.rb @@ -22,12 +22,14 @@ module Fiddle def test_static_sym_unknown assert_raise(DLError) { Fiddle::Handle.sym('fooo') } assert_raise(DLError) { Fiddle::Handle['fooo'] } + refute Fiddle::Handle.sym_defined?('fooo') end def test_static_sym begin # Linux / Darwin / FreeBSD refute_nil Fiddle::Handle.sym('dlopen') + assert Fiddle::Handle.sym_defined?('dlopen') assert_equal Fiddle::Handle.sym('dlopen'), Fiddle::Handle['dlopen'] return rescue @@ -54,6 +56,7 @@ module Fiddle handle = Fiddle::Handle.new(LIBC_SO) assert_raise(DLError) { handle.sym('fooo') } assert_raise(DLError) { handle['fooo'] } + refute handle.sym_defined?('fooo') end def test_sym_with_bad_args @@ -66,6 +69,7 @@ module Fiddle handle = Handle.new(LIBC_SO) refute_nil handle.sym('calloc') refute_nil handle['calloc'] + assert handle.sym_defined?('calloc') end def test_handle_close @@ -179,12 +183,18 @@ module Fiddle # it calls _nss_cache_cycle_prevention_function with dlsym(3). # So our Fiddle::Handle#sym must call dlerror(3) before call dlsym. # In general uses of dlerror(3) should call it before use it. + verbose, $VERBOSE = $VERBOSE, nil require 'socket' Socket.gethostbyname("localhost") Fiddle.dlopen("/lib/libc.so.7").sym('strcpy') + ensure + $VERBOSE = verbose end if /freebsd/=~ RUBY_PLATFORM def test_no_memory_leak + # https://github.com/ruby/fiddle/actions/runs/3202406059/jobs/5231356410 + omit if RUBY_VERSION >= '3.2' + if respond_to?(:assert_nothing_leaked_memory) n_tries = 100_000 assert_nothing_leaked_memory(SIZEOF_VOIDP * (n_tries / 100)) do |