Permalink
Browse files

fix tests for netbsd

  • Loading branch information...
1 parent e07799a commit 39febea8d7ed13e1ebc8747fd6fae09f475e6c17 @tduehr tduehr committed Jul 1, 2014
Showing with 60 additions and 10 deletions.
  1. +18 −3 bench/bench_buffer.rb
  2. +18 −3 bench/bench_struct.rb
  3. +6 −1 spec/ffi/pointer_spec.rb
  4. +12 −2 spec/ffi/struct_spec.rb
  5. +6 −1 spec/ffi/typedef_spec.rb
View
@@ -9,9 +9,24 @@ module BufferBench
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s32_v, [ :int ], :void
- attach_function :bench_buffer_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
- attach_function :bench_buffer_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
- attach_function :bench_buffer_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ begin
+ attach_function :bench_buffer_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_in, :ptr_ret___int32_t, [ :buffer_in, :int ], :void
+ end
+ begin
+ attach_function :bench_buffer_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_inout, :ptr_ret___int32_t, [ :buffer_inout, :int ], :void
+ end
+ begin
+ attach_function :bench_buffer_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_buffer_out, :ptr_ret___int32_t, [ :buffer_out, :int ], :void
+ end
end
class IntStruct < FFI::Struct
layout :i, :int
View
@@ -8,9 +8,24 @@ module StructBench
extend FFI::Library
ffi_lib LIBTEST_PATH
attach_function :bench_s32_v, [ :int ], :void
- attach_function :bench_struct_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
- attach_function :bench_struct_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
- attach_function :bench_struct_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ begin
+ attach_function :bench_struct_in, :ptr_ret_int32_t, [ :buffer_in, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_in, :ptr_ret___int32_t, [ :buffer_in, :int ], :void
+ end
+ begin
+ attach_function :bench_struct_out, :ptr_ret_int32_t, [ :buffer_out, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_out, :ptr_ret___int32_t, [ :buffer_out, :int ], :void
+ end
+ begin
+ attach_function :bench_struct_inout, :ptr_ret_int32_t, [ :buffer_inout, :int ], :void
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :bench_struct_inout, :ptr_ret___int32_t, [ :buffer_inout, :int ], :void
+ end
end
class TestStruct < FFI::Struct
layout :i, :int, :p, :pointer
@@ -10,7 +10,12 @@
module PointerTestLib
extend FFI::Library
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
attach_function :ptr_set_pointer, [ :pointer, :int, :pointer ], :void
attach_function :ptr_ret_pointer, [ :pointer, :int ], :pointer
@@ -20,7 +20,12 @@ module LibTest
extend FFI::Library
ffi_lib TestLibrary::PATH
attach_function :ptr_ret_pointer, [ :pointer, :int], :string
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
attach_function :ptr_from_address, [ :ulong ], :pointer
attach_function :string_equals, [ :string, :string ], :int
[ 's8', 's16', 's32', 's64', 'f32', 'f64', 'long' ].each do |t|
@@ -401,7 +406,12 @@ module FFISpecs
module LibTest
extend FFI::Library
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ begin
+ attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :pointer, :int ], :int
+ end
end
end
@@ -62,7 +62,12 @@ class S < FFI::Struct
typedef :int, :bar
ffi_lib TestLibrary::PATH
- attach_function :ptr_ret_int32_t, [ :string, :foo ], :bar
+ begin
+ attach_function :ptr_ret_int32_t, [ :string, :foo ], :bar
+ rescue FFI::NotFoundError
+ # NetBSD uses #define instead of typedef for these
+ attach_function :ptr_ret_int32_t, :ptr_ret___int32_t, [ :string, :foo ], :bar
+ end
end
end.should_not raise_error
end

0 comments on commit 39febea

Please sign in to comment.