From cc8b3517ed024dd4c593d18de85814727fbc7238 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 7 Mar 2009 17:21:40 +0000 Subject: [PATCH] use ldd to find libc and libm if no information. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/dl/test_base.rb | 63 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/test/dl/test_base.rb b/test/dl/test_base.rb index be23ffa35c..48b32cddea 100644 --- a/test/dl/test_base.rb +++ b/test/dl/test_base.rb @@ -1,13 +1,16 @@ 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" + libc_so = "cygwin1.dll" + libm_so = "cygwin1.dll" when /x86_64-linux/ - LIBC_SO = "/lib64/libc.so.6" - LIBM_SO = "/lib64/libm.so.6" + libc_so = "/lib64/libc.so.6" + libm_so = "/lib64/libm.so.6" when /linux/ libdir = '/lib' case [0].pack('L!').size @@ -18,40 +21,40 @@ when /linux/ # 64-bit ruby libdir = '/lib64' if File.directory? '/lib64' end - LIBC_SO = [ - File.join(libdir, "libc.so.6"), - File.join(libdir, "libc.so.6.1") - ].find {|f| File.file? f } - LIBM_SO = [ - File.join(libdir, "libm.so.6"), - File.join(libdir, "libm.so.6.1") - ].find {|f| File.file? f } + libc_so = File.join(libdir, "libc.so.6") + libm_so = File.join(libdir, "libm.so.6") when /mingw/, /mswin32/ - LIBC_SO = "msvcrt.dll" - LIBM_SO = "msvcrt.dll" + libc_so = "msvcrt.dll" + libm_so = "msvcrt.dll" when /darwin/ - LIBC_SO = "/usr/lib/libc.dylib" - LIBM_SO = "/usr/lib/libm.dylib" + 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" -when /solaris2/ - case [0].pack('L!').size - when 4 - libdir = '/usr/lib' - when 8 - libdir = '/usr/lib/64' - end - LIBC_SO = "#{libdir}/libc.so" - LIBM_SO = "#{libdir}/libm.so" + libc_so = "/usr/lib/libc.so" + libm_so = "/usr/lib/libm.so" else - LIBC_SO = ARGV[0] - LIBM_SO = ARGV[1] - if( !(LIBC_SO && LIBM_SO) ) + libc_so = ARGV[0] + libm_so = ARGV[1] + if( !(libc_so && libm_so) ) $stderr.puts("libc and libm not found: #{$0} ") end end +libc_so = nil if !libc_so || !File.file?(libc_so) +libm_so = nil if !libm_so || !File.file?(libm_so) + +if !libc_so || !libm_so + ruby = EnvUtil.rubybin + ldd = `ldd #{ruby}` + #puts ldd + libc_so = $1 if !libc_so && %r{libc\.so.*=>\s+(/\S*)} =~ ldd + libm_so = $1 if !libm_so && %r{libm\.so.*=>\s+(/\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