about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-23 20:52:26 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-23 20:52:26 -0800
commitc02944edaed780bb20ad98ecdd11463d945b36ca (patch)
treee4c4302bc9136d07a5105ad2893647734a68352d
parentc57db265632314a663268aceb1213ce6a7d8c83f (diff)
downloadruby_posix_mq-c02944edaed780bb20ad98ecdd11463d945b36ca.tar.gz
-rw-r--r--test/test_posix_mq.rb28
1 files changed, 11 insertions, 17 deletions
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index 4a661e8..a7ea3b6 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -4,6 +4,7 @@ require 'posix_mq'
 require 'thread'
 require 'fcntl'
 $stderr.sync = $stdout.sync = true
+require "dl"
 
 class Test_POSIX_MQ < Test::Unit::TestCase
 
@@ -97,24 +98,17 @@ class Test_POSIX_MQ < Test::Unit::TestCase
   end
 
   def test_alarm_signal_safe
-    alarm = nil
-    libcs = %w(/lib/libc-2.7.so /usr/lib/libc.sl)
-    libcs.each do |libc|
-      if File.readable?(libc)
-        require "dl"
-        begin
-          require "fiddle"
-        rescue LoadError
-        end
-        libc = DL.dlopen libc
-        if defined?(Fiddle)
-          alarm = libc["alarm"]
-          alarm = Fiddle::Function.new(alarm, [DL::TYPE_INT], DL::TYPE_INT)
-        else
-          alarm = libc["alarm", "II"]
-        end
-        break
+    libc = alarm = nil
+    libcs = %w(libc.so.6 /usr/lib/libc.sl)
+    libcs.each do |name|
+      libc = DL::Handle.new(name) rescue next
+      if defined?(Fiddle)
+        alarm = libc["alarm"]
+        alarm = Fiddle::Function.new(alarm, [DL::TYPE_INT], DL::TYPE_INT)
+      else
+        alarm = libc["alarm", "II"]
       end
+      break
     end
     alarm or return warn "alarm() not found in #{libcs.inspect}"
     alarms = 0