1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/dl/test_base.rb
tenderlove b386fe21ec Wed Feb 3 10:12:09 2010 Aaron Patterson <tenderlove@ruby-lang.org>
* ext/dl/function.c: DL::Function now uses libffi

        * ext/dl/cfunc.c (rb_dl_set_last_error): set to non static so errors
          can be exposed.

        * ext/dl/closure.c: DL::Closure will now be used in place of
          ext/dl/callback/*.

        * ext/dl/dl.c: legacy callbacks removed in favor of libffi

        * ext/dl/dl_converions.(c,h): used for converting ruby types to FFI
          types.

        * ext/dl/callback/*: replaced by libffi callbacks.

        * ext/dl/lib/dl/callback.rb: Converting internal callbacks to use
          DL::Closure

        * ext/dl/lib/dl/closure.rb: Ruby parts of the new DL::Closure object

        * ext/dl/lib/dl/import.rb: More conversion to use DL::Closure object

        * ext/dl/lib/dl/value.rb (ruby2ffi): adding private method for
          DL::CPtr to ffi value conversion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-03 01:23:48 +00:00

87 lines
1.9 KiB
Ruby

require 'test/unit'
require 'dl'
require_relative '../ruby/envutil'
libc_so = libm_so = nil
case RUBY_PLATFORM
when /cygwin/
libc_so = "cygwin1.dll"
libm_so = "cygwin1.dll"
when /x86_64-linux/
libc_so = "/lib64/libc.so.6"
libm_so = "/lib64/libm.so.6"
when /linux/
libdir = '/lib'
case [0].pack('L!').size
when 4
# 32-bit ruby
libdir = '/lib32' if File.directory? '/lib32'
when 8
# 64-bit ruby
libdir = '/lib64' if File.directory? '/lib64'
end
libc_so = File.join(libdir, "libc.so.6")
libm_so = File.join(libdir, "libm.so.6")
when /mingw/, /mswin/
require "rbconfig"
libc_so = libm_so = RbConfig::CONFIG["RUBY_SO_NAME"].split(/-/, 2)[0] + ".dll"
when /darwin/
libc_so = "/usr/lib/libc.dylib"
libm_so = "/usr/lib/libm.dylib"
when /bsd|dragonfly/
libc_so = "/usr/lib/libc.so"
libm_so = "/usr/lib/libm.so"
else
libc_so = ARGV[0] if ARGV[0] && ARGV[0][0] == ?/
libm_so = ARGV[1] if ARGV[1] && ARGV[1][0] == ?/
if( !(libc_so && libm_so) )
$stderr.puts("libc and libm not found: #{$0} <libc> <libm>")
end
end
libc_so = nil if !libc_so || (libc_so[0] == ?/ && !File.file?(libc_so))
libm_so = nil if !libm_so || (libm_so[0] == ?/ && !File.file?(libm_so))
if !libc_so || !libm_so
ruby = EnvUtil.rubybin
ldd = `ldd #{ruby}`
#puts ldd
libc_so = $& if !libc_so && %r{/\S*/libc\.so\S*} =~ ldd
libm_so = $& if !libm_so && %r{/\S*/libm\.so\S*} =~ ldd
#p [libc_so, libm_so]
end
DL::LIBC_SO = libc_so
DL::LIBM_SO = libm_so
module DL
class TestBase < Test::Unit::TestCase
include Math
include DL
def setup
@libc = dlopen(LIBC_SO)
@libm = dlopen(LIBM_SO)
end
def assert_match(expected, actual, message="")
assert(expected === actual, message)
end
def assert_positive(actual)
assert(actual > 0)
end
def assert_zero(actual)
assert_equal(0, actual)
end
def assert_negative(actual)
assert(actual < 0)
end
def test_empty()
end
end
end