2009-09-10 13:14:53 -04:00
|
|
|
require_relative 'test_base'
|
2009-09-10 08:22:59 -04:00
|
|
|
require_relative '../ruby/envutil'
|
2009-09-07 19:32:32 -04:00
|
|
|
|
|
|
|
module DL
|
|
|
|
class TestCPtr < TestBase
|
|
|
|
def test_free
|
|
|
|
ptr = CPtr.malloc(4)
|
|
|
|
assert_nil ptr.free
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_free=
|
2009-09-10 08:22:59 -04:00
|
|
|
assert_normal_exit(<<-"End", '[ruby-dev:39269]')
|
|
|
|
require 'dl'
|
|
|
|
DL::LIBC_SO = #{DL::LIBC_SO.dump}
|
|
|
|
DL::LIBM_SO = #{DL::LIBM_SO.dump}
|
|
|
|
include DL
|
|
|
|
@libc = dlopen(LIBC_SO)
|
|
|
|
@libm = dlopen(LIBM_SO)
|
|
|
|
free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
|
|
|
|
ptr = CPtr.malloc(4)
|
|
|
|
ptr.free = free
|
|
|
|
free.ptr
|
|
|
|
ptr.free.ptr
|
|
|
|
End
|
|
|
|
|
2009-09-07 19:32:32 -04:00
|
|
|
free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
|
|
|
|
ptr = CPtr.malloc(4)
|
|
|
|
ptr.free = free
|
|
|
|
|
|
|
|
assert_equal free.ptr, ptr.free.ptr
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|