summaryrefslogtreecommitdiff
path: root/spec/ffi/variadic_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ffi/variadic_spec.rb')
-rw-r--r--spec/ffi/variadic_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/ffi/variadic_spec.rb b/spec/ffi/variadic_spec.rb
index 4138280..0c7292e 100644
--- a/spec/ffi/variadic_spec.rb
+++ b/spec/ffi/variadic_spec.rb
@@ -13,6 +13,11 @@ describe "Function with variadic arguments" do
enum :enum_type2, [:c3, 42, :c4]
attach_function :pack_varargs, [ :buffer_out, :string, :varargs ], :void
attach_function :pack_varargs2, [ :buffer_out, :enum_type1, :string, :varargs ], :enum_type1
+
+ attach_function :testBlockingOpen, [ ], :pointer
+ attach_function :testBlockingRWva, [ :pointer, :char, :varargs ], :char, :blocking => true
+ attach_function :testBlockingWRva, [ :pointer, :char, :varargs ], :char, :blocking => true
+ attach_function :testBlockingClose, [ :pointer ], :void
end
it "takes enum arguments" do
@@ -27,6 +32,20 @@ describe "Function with variadic arguments" do
expect(LibTest.pack_varargs2(buf, :c1, "ii", :int, :c3, :int, :c4)).to eq(:c2)
end
+ it 'can wrap a blocking function with varargs' do
+ pending("not supported in 1.8") if RUBY_VERSION =~ /^1\.8\..*/
+ handle = LibTest.testBlockingOpen
+ expect(handle).not_to be_null
+ begin
+ thWR = Thread.new { LibTest.testBlockingWRva(handle, 63, :int, 40, :int, 23, :int, 0) }
+ thRW = Thread.new { LibTest.testBlockingRWva(handle, 64, :int, 40, :int, 24, :int, 0) }
+ expect(thWR.value).to eq(64)
+ expect(thRW.value).to eq(63)
+ ensure
+ LibTest.testBlockingClose(handle)
+ end
+ end
+
[ 0, 127, -128, -1 ].each do |i|
it "call variadic with (:char (#{i})) argument" do
buf = FFI::Buffer.new :long_long