diff options
author | tduehr <td@matasano.com> | 2016-07-06 08:58:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 08:58:34 -0500 |
commit | e3183e2d19fd7f01c5e07225eaaa9ea51a6ed892 (patch) | |
tree | 6b8b32e44884870e4d6fe2f7ebc9d6bd8de12ca7 | |
parent | f73c2e843f7eea39a0a2a49ffc19560ccb1ee029 (diff) | |
parent | cfc22902f01875fc7261bdab14677ee6865a891a (diff) | |
download | ffi-e3183e2d19fd7f01c5e07225eaaa9ea51a6ed892.tar.gz |
Merge pull request #508 from mwrock/symbol
fix library loading by symbol with test
-rw-r--r-- | lib/ffi/library.rb | 3 | ||||
-rw-r--r-- | spec/ffi/library_spec.rb | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/ffi/library.rb b/lib/ffi/library.rb index 85406c1..a88e6f1 100644 --- a/lib/ffi/library.rb +++ b/lib/ffi/library.rb @@ -123,7 +123,8 @@ module FFI end # TODO better library lookup logic - unless libname.to_s.start_with?("/") + libname = libname.to_s + unless libname.start_with?("/") path = ['/usr/lib/','/usr/local/lib/'].find do |pth| File.exist?(pth + libname) end diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index 4359b93..c4900d3 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -96,6 +96,16 @@ describe "Library" do }.not_to raise_error end + it "loads library using symbol" do + expect { + expect(Module.new do |m| + m.extend FFI::Library + ffi_lib :c + attach_function :getpid, [ ], :uint + end.getpid).to eq(Process.pid) + }.not_to raise_error + end + it "attach_function :getpid from [ 'c', 'libc.so.6'] " do expect { expect(Module.new do |m| |