From c57db265632314a663268aceb1213ce6a7d8c83f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 23 Feb 2011 20:43:09 -0800 Subject: [PATCH] fix test alarm() case for Ruby 1.9 DL in Ruby 1.9 isn't the same --- test/test_posix_mq.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb index 3dcaa90..4a661e8 100644 --- a/test/test_posix_mq.rb +++ b/test/test_posix_mq.rb @@ -102,8 +102,17 @@ class Test_POSIX_MQ < Test::Unit::TestCase libcs.each do |libc| if File.readable?(libc) require "dl" + begin + require "fiddle" + rescue LoadError + end libc = DL.dlopen libc - alarm = libc["alarm", "II"] + 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 end @@ -111,7 +120,7 @@ class Test_POSIX_MQ < Test::Unit::TestCase alarms = 0 trap("ALRM") { alarms += 1 } interval = 1 - alarm[interval] + alarm.call interval @mq = POSIX_MQ.new(@path, :rw) assert ! @mq.nonblock? t0 = Time.now -- 2.11.4.GIT