summaryrefslogtreecommitdiff
path: root/test/fiddle
AgeCommit message (Collapse)Author
2024-12-16[ruby/fiddle] ffi_backend: convert numeric function args to pointersDani Smith
(https://github.com/ruby/fiddle/pull/162) This allows for passing integers as pointer arguments to functions when using the FFI backend. This is a workaround until we can get JRuby's FFI implementation to allow for it directly (see also https://github.com/jruby/jruby/pull/8423) --------- https://github.com/ruby/fiddle/commit/e2f0952e9b Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-12-11[ruby/fiddle] dlopen: add support for INPUT(-lXXX)Sutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/166 Arch Linux's libncurses.so uses this style. https://github.com/ruby/fiddle/commit/77d3dc934f
2024-12-11[ruby/fiddle] Implement `Fiddle::Pointer.read` and `.write` on theLars Kanis
FFI backend (https://github.com/ruby/fiddle/pull/165) https://github.com/ruby/fiddle/commit/0bd963d3b8
2024-12-11[ruby/fiddle] Fix the glob pattern to include `/usr/lib`Nobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/164) Fix up #161. https://github.com/ruby/fiddle/commit/481651e836
2024-12-10[ruby/fiddle] Fix test_dlopen_linker_script_input_linux beingDani Smith
omitted on Fedora 40 aarch64 (https://github.com/ruby/fiddle/pull/161) I found working on Fedora 40 on aarch64 that `test_dlopen_linker_script_input_linux` was omitted due to not finding libncurses.so, since it is in /usr/lib64. This PR makes the glob a little more portable. https://github.com/ruby/fiddle/commit/444774c0c4
2024-11-11[ruby/fiddle] Accept Symbol as Function name againSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/159 It's used by FFI test. So Symbol may be used by other use cases. https://github.com/ruby/fiddle/pull/139 introduced the "Function name is String" limitation. This commit removed the limitation. Reported by Mamoru TASAKA. Thanks!!! https://github.com/ruby/fiddle/commit/cea30fe5f9
2024-10-26[ruby/fiddle] Fix Fiddle::Handle.new for a missing library in theBenoit Daloze
FFI backend (https://github.com/ruby/fiddle/pull/156) * From https://github.com/ruby/reline/issues/766#issuecomment-2422135968 https://github.com/ruby/fiddle/commit/eea9fd0cc4
2024-10-18[ruby/fiddle] test: Fix a typokojix2
(https://github.com/ruby/fiddle/pull/154) https://github.com/ruby/fiddle/commit/1f818e4684
2024-10-16Use JRuby implementation for TruffleRuby (#149)Sutou Kouhei
Fix GH-145 Rename `lib/fiddle/jruby.rb` to `lib/fiddle/ffi_backend.rb` as a generic ffi gem API based implementation. JRuby and TruffleRuby use `lib/fiddle/ffi_backend.rb`. --------- Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2024-10-16[ruby/fiddle] Ractor supportNobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/139) https://github.com/ruby/fiddle/commit/91d0ea9849 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2024-10-10[ruby/fiddle] Only print Fiddle::VERSION when flag is trueHiroshi SHIBATA
(https://github.com/ruby/fiddle/pull/151) The test of current HEAD revision occurred `unknown command` on `ruby/ruby` repo. ``` $ make test-all -j TESTS="fiddle -j12" MSPECOPT="-j" (snip) # Running tests: unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686:waiting 58687=test_pinne unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 58687=test_ unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_pack 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 58687=test_ unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_fiddle 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 5868 unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_union_entity 58686=test_cparser 586 unknown command: "Fiddle::VERSION: 1.1.3.dev" unknown command: "Fiddle::VERSION: 1.1.3.dev" unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5 unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5 unknown command: "Fiddle::VERSION: 1.1.3.dev"8681=test_closure 58682=test_memory_view 58683=test_handle 58684=test_import 58685=test_c_struct_builder 58686=test_cparser 5 Finished tests in 1.136194s, 194.5090 tests/s, 929.4187 assertions/s. 221 tests, 1056 assertions, 0 failures, 0 errors, 4 skips ``` I only show fiddle version in this repository with `$VERSBOSE` flag. https://github.com/ruby/fiddle/commit/31bebd85be
2024-10-10Revert "Commented out to print fiddle version"Hiroshi SHIBATA
This reverts commit a1db8dbe166d82d7238b3d375344799e057dab2b.
2024-10-10Commented out to print fiddle versionHiroshi SHIBATA
2024-10-10[ruby/fiddle] test jruby: fix a typoSutou Kouhei
https://github.com/ruby/fiddle/commit/d76c87b804 Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-10-10[ruby/fiddle] test jruby: fix a wrong messageSutou Kouhei
https://github.com/ruby/fiddle/commit/00b3521f5e Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-10-10[ruby/fiddle] test jruby: fix a typoSutou Kouhei
https://github.com/ruby/fiddle/commit/5bc55e0533 Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-10-10Import JRuby implementation (#147)Sutou Kouhei
Fix GH-104 lib/fiddle/jruby.rb is based on https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle/jruby.rb . Here are changes for it: * Move `Fiddle::TYPE_*` to `Fiddle::Types::*` * Add `Fiddle::Types::VARIADIC` * Add `Fiddle::Types::CONST_STRING` * Add `Fiddle::Types::BOOL` * Add `Fiddle::Types::INT8_T` * Add `Fiddle::Types::UINT8_T` * Add `Fiddle::Types::INT16_T` * Add `Fiddle::Types::UINT16_T` * Add `Fiddle::Types::INT32_T` * Add `Fiddle::Types::UINT32_T` * Add `Fiddle::Types::INT64_T` * Add `Fiddle::Types::UINT64_T` * Add more `Fiddle::ALIGN_*` for the above new `Fiddle::Types::*` * Add more `Fiddle::SIZEOF_*` for the above new `Fiddle::Types::*` * Add support for specifying type as not only `Fiddle::Types::*` but also `Symbol` like `:int` * Add support for variable size arguments in `Fiddle::Function` * Add `Fiddle::Closure#free` * Add `Fiddle::Closure#freed?` * Add `Fiddle::Error` as base the error class * Add `Fiddle::Pointer#call_free` and stop using `FFI::AutoPointer` in `Fiddle::Pointer` * Add support for `Fiddle::Pointer.malloc {}` `Fiddle::Pointer` * Add support for `Fiddle::Pointer#free=` * Add `Fiddle::Pointer#freed?` * Use binary string not C string for `Fiddle::Pointer#[]` * Add `Fiddle::Handle.sym_defined?` * Add `Fiddle::Handle#sym_defined?` * Add `Fiddle::Handle::DEFAULT` * Add `Fiddle::ClearedReferenceError` * Add no-op `Fiddle::Pinned` Some features are still "not implemented". So there are some "omit"s for JRuby in tests. Notes: Merged: https://github.com/ruby/ruby/pull/11860
2024-10-02[ruby/fiddle] test memory-view: ensure releasing in testSutou Kouhei
It's for avoiding calling release on exit via GC. If it's happen, Ruby will be crashed because Fiddle::MemoryView's finalizer may refer other Ruby object. In exit phrase, the referred Ruby object may be already freed. https://github.com/ruby/fiddle/commit/02915f13de
2024-10-02[ruby/fiddle] test: remove fragile memory leak testsSutou Kouhei
https://github.com/ruby/fiddle/commit/0bfcd02bef
2024-07-02[ruby/fiddle] Pick ruby/ruby changes forHiroshi SHIBATA
`test/fiddle/test_function.rb` (https://github.com/ruby/fiddle/pull/141) https://github.com/ruby/ruby/pull/11048#issuecomment-2185630854 --------- https://github.com/ruby/fiddle/commit/a245f19763 Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2024-06-24Extend the timeout of Fiddle::TestFunction#test_nogvl_pollYusuke Endoh
2023-12-25suppress a warningNARUSE, Yui
2023-11-08[ruby/fiddle] Use Ruby's true/false for C boolSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/130 Reported by Benoit Daloze. Thanks!!! https://github.com/ruby/fiddle/commit/2640e0148e
2023-08-02[ruby/fiddle] Add support for boolSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/130 Reported by Benoit Daloze. Thanks!!! https://github.com/ruby/fiddle/commit/bc6c66bbb9
2023-06-28[ruby/fiddle] Add support for more "short" variantsSutou Kouhei
https://github.com/ruby/fiddle/commit/4598e6cd50
2023-06-28[ruby/fiddle] Add support for "long" variantsSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/100 Reported by David M. Lary. Thanks!!! https://github.com/ruby/fiddle/commit/516333dd78
2023-06-28[ruby/fiddle] Add a helper method for reading/writing memoryAaron Patterson
(https://github.com/ruby/fiddle/pull/123) This commit adds two new methods, `Fiddle::Pointer.read` and `Fiddle::Pointer.write`. Both methods take an address, and will read or write bytes at that address respectively. For example we can read from an address without making a Pointer object: ```ruby Fiddle::Pointer.read(address, 5) # read 5 bytes ``` We can also write to an address without allocating a Pointer object: ```ruby Fiddle::Pointer.write(address, "bytes") # write 5 bytes ``` This allows us to read / write memory at arbitrary addresses without instantiating a new `Fiddle::Pointer` object. Examples where this API would be useful [1](https://github.com/tenderlove/tenderjit/blob/f03481d28bff4d248746e596929b0841de65f181/lib/tenderjit/fiddle_hacks.rb#L26-L28) [2](https://github.com/tenderlove/ruby/blob/77c8daa2d40dd58eeb3785ce17dea2ee38f308d1/lib/ruby_vm/rjit/c_pointer.rb#L193) [3](https://github.com/tenderlove/ruby/blob/77c8daa2d40dd58eeb3785ce17dea2ee38f308d1/lib/ruby_vm/rjit/c_pointer.rb#L284) I also added a writer method for the same reasons as the reader. --------- https://github.com/ruby/fiddle/commit/04238cefed Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-12-09Merge fiddle-1.1.1Hiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/6890
2022-10-18[ruby/fiddle] Add support for linker script on LinuxSutou Kouhei
GitHub: fix https://github.com/ruby/fiddle/pull/107 Reported by nicholas a. evans. Thanks!!! https://github.com/ruby/fiddle/commit/49ea1490df Notes: Merged: https://github.com/ruby/ruby/pull/6576
2022-10-18[ruby/fiddle] Fix filenames for glibc SO files on alpha and ia64John Paul Adrian Glaubitz
(https://github.com/ruby/fiddle/pull/105) Fixes [Bug #18645] https://github.com/ruby/fiddle/commit/9a5a1dab1d Notes: Merged: https://github.com/ruby/ruby/pull/6576
2022-10-07Add --with-libffi-source-dir feature and removed --enable-bundled-libffi ↵Hiroshi SHIBATA
option. (#113) https://bugs.ruby-lang.org/issues/18571 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07[ruby/fiddle] test: don't use assert_true/assert_falseSutou Kouhei
GitHub: GH-102 They aren't available in ruby/ruby. https://github.com/ruby/fiddle/commit/ced671e43b
2022-10-07[ruby/fiddle] test: ensure freeing closureSutou Kouhei
GitHub: GH-102 https://github.com/ruby/fiddle/commit/b2fef1770d
2022-10-07[ruby/fiddle] test: ensure freeing closureSutou Kouhei
GitHub: GH-102 This also improves freed closures assertions. https://github.com/ruby/fiddle/commit/0495624caf
2022-10-07[ruby/fiddle] test: don't use power-assertSutou Kouhei
It seems that we can't use it in ruby/ruby. https://github.com/ruby/fiddle/commit/e1221297fb
2022-10-07[ruby/fiddle] test: ensure freeing closureSutou Kouhei
GitHub: GH-102 This also improves freed closures assertions. https://github.com/ruby/fiddle/commit/f6431f3cf8
2022-10-07[ruby/fiddle] Add Fiddle::Closure.create and Fiddle::Closure.freeSutou Kouhei
GitHub: fix GH-102 It's for freeing a closure explicitly. We can't use Fiddle::Closure before we fork the process. If we do it, the process may be crashed with SELinux. See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091 for details. Reported by Vít Ondruch. Thanks!!! https://github.com/ruby/fiddle/commit/a0ccc6bb1b
2022-10-07[ruby/fiddle] test: suppress a warningSutou Kouhei
test/fiddle/test_import.rb:138: warning: ambiguous first argument; put parentheses or a space even after `-' operator https://github.com/ruby/fiddle/commit/060eef76ad
2022-10-07[ruby/fiddle] Add `sym_defined?` methods to test if a symbol is defined ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/108) I would like to check if a symbol is defined before trying to access it. Some symbols aren't available on all platforms, so instead of raising an exception, I want to check if it's defined first. Today we have to do: ```ruby begin addr = Fiddle::Handle.sym("something") # do something rescue Fiddle::DLError end ``` I want to write this: ```ruby if Fiddle::Handle.sym_defined?("something") addr = Fiddle::Handle.sym("something") # do something end ``` https://github.com/ruby/fiddle/commit/9d3371de13 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07[ruby/fiddle] Move "type" constants to `Fiddle::Types` ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/112) This helps to reduce repetition in code. Instead of doing "TYPE_*" everywhere, you can do `include Fiddle::Types`, and write the type name directly. This PR is to help reduce repetition when writing Fiddle code. Right now we have to type `TYPE_` everywhere, and you also have to include all of `Fiddle` to access `TYPE_*` constants. With this change, you can just include `Fiddle::Types` and it will shorten your code and also you only have to include those constants. Here is an example before: ```ruby require "fiddle" module MMAP # All Fiddle constants included include Fiddle def self.make_function name, args, ret ptr = Handle::DEFAULT[name] func = Function.new ptr, args, ret, name: name define_singleton_method name, &func.to_proc end make_function "munmap", [TYPE_VOIDP, # addr TYPE_SIZE_T], # len TYPE_INT make_function "mmap", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT], TYPE_VOIDP make_function "mprotect", [TYPE_VOIDP, TYPE_SIZE_T, TYPE_INT], TYPE_INT end ``` After: ```ruby require "fiddle" module MMAP # Only type names included include Fiddle::Types def self.make_function name, args, ret ptr = Fiddle::Handle::DEFAULT[name] func = Fiddle::Function.new ptr, args, ret, name: name define_singleton_method name, &func.to_proc end make_function "munmap", [VOIDP, # addr SIZE_T], # len INT make_function "mmap", [VOIDP, SIZE_T, INT, INT, INT, INT], VOIDP make_function "mprotect", [VOIDP, SIZE_T, INT], INT end ``` We only need to import the type names, and you don't have to type `TYPE_` over and over. I think this makes Fiddle code easier to read. https://github.com/ruby/fiddle/commit/49fa7233e5 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07[ruby/fiddle] Add constants for unsigned values ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/111) This commit adds constants for unsigned values. Currently we can use `-` to mean "unsigned", but I think having a specific name makes Fiddle more user friendly. This commit continues to support `-`, but introduces negative constants with "unsigned" names I think this will help to eliminate [this code](https://github.com/ruby/ruby/blob/3a56bf0bcc66e14ffe5ec89efc32ecfceed180f4/lib/mjit/c_type.rb#L31-L38) https://github.com/ruby/fiddle/commit/2bef0f1082 Co-authored-by: Sutou Kouhei <kou@clear-code.com>
2022-10-07[ruby/fiddle] test: ensure GC-ing closuresSutou Kouhei
GitHub: fix GH-102 We can't use Fiddle::Closure before we fork the process. If we do it, the process may be crashed with SELinux. See https://github.com/ruby/fiddle/issues/102#issuecomment-1241763091 for details. Reported by Vít Ondruch. Thanks!!! https://github.com/ruby/fiddle/commit/1343ac7a95
2022-09-11[ruby/fiddle] Fix PACK_MAP for unsigned types ↵Takashi Kokubun
(https://github.com/ruby/fiddle/pull/110) https://github.com/ruby/fiddle/commit/4a71246645ccff001292c9d80b855b2ef5bf06c1
2021-09-05[ruby/fiddle] Use test-unit gem (https://github.com/ruby/fiddle/pull/69)Hiroshi SHIBATA
https://github.com/ruby/fiddle/commit/e08c4c635e Co-authored-by: Sutou Kouhei <kou@clear-code.com> Notes: Merged: https://github.com/ruby/ruby/pull/4810
2021-08-24[ruby/fiddle] Simplify libc and libm path logics ↵Nobuyoshi Nakada
(https://github.com/ruby/fiddle/pull/91) * Simplify libc_so and libm_so If nil, no need to set to nil. * Get rid of repeating inversions https://github.com/ruby/fiddle/commit/4323e689d8
2021-08-24[ruby/fiddle] Improve "offsetof" calculations ↵Aaron Patterson
(https://github.com/ruby/fiddle/pull/90) I need to get the offset of members inside sub structures. This patch adds sub-structure offset support for structs. https://github.com/ruby/fiddle/commit/cf78eddbb6
2021-07-15[ruby/fiddle] Handle#file_name results in very platform dependentNobuyoshi Nakada
2021-07-15[ruby/fiddle] Module file name may be the realpathNobuyoshi Nakada
Even when the path which was used to dlopen may be a symlink.
2021-07-14[ruby/fiddle] fixed the test on case-insensitive filesystemNobuyoshi Nakada
2021-07-14[ruby/fiddle] Add Fiddle::Handle#file_name ↵Kenta Murata
(https://github.com/ruby/fiddle/pull/88) https://github.com/ruby/fiddle/commit/4ee1c6fc4b