aboutsummaryrefslogtreecommitdiffstats
path: root/test/fiddle
Commit message (Collapse)AuthorAgeFilesLines
* Oops! Add another test and fix to_proc implementationAaron Patterson2021-02-261-0/+11
|
* Fiddle::Function responds to to_procAaron Patterson2021-02-261-0/+13
| | | | | | | | | | This lets us cast a Fiddle::Function to a block, allowing is to write things like: ```ruby f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP) define_method :strcpy, &f ```
* [memory_view][fiddle] Rename len to byte_size in rb_memory_view_tKenta Murata2020-12-231-5/+5
|
* TEST: multiarch support for HaikuZoltán Mizsei2020-12-151-0/+12
|
* Strip trailing spaces [ci skip]Nobuyoshi Nakada2020-12-111-1/+1
|
* Import fiddle-1.0.4 (#3860)Kenta Murata2020-12-117-89/+707
| | | | | | | | I don't use tool/sync_default_gem.rb because the last sync was incomplete. Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org> Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Co-authored-by: sinisterchipmunk <sinisterchipmunk@gmail.com> Co-authored-by: Sutou Kouhei <kou@clear-code.com>
* Revert "test/fiddle/helper.rb: remove duplication (#3863)" (#3865)Kenta Murata2020-12-081-1/+5
| | | | | | This reverts commit bd47a8d660ab33a20c5e28d0effcc29105c434e4. `libc_so` and `libm_so` are `nil` at line 124 because Big Sur doesn't have `/usr/lib/libSystem.B.dylib`. The reassignment at line 127 is necessary in this case.
* test/fiddle/helper.rb: remove duplication (#3863)Kenta Murata2020-12-081-5/+1
|
* [ruby/fiddle] test: suppress shadowing outer local variable warningSutou Kouhei2020-11-181-2/+2
| | | | https://github.com/ruby/fiddle/commit/cf168680a2
* [ruby/fiddle] Add a "pinning" reference (#44)Aaron Patterson2020-11-181-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a "pinning" reference A `Fiddle::Pinned` objects will prevent the objects they point to from moving. This is useful in the case where you need to pass a reference to a C extension that keeps the address in a global and needs the address to be stable. For example: ```ruby class Foo A = "hi" # this is an embedded string some_c_function A # A might move! end ``` If `A` moves, then the underlying string buffer may also move. `Fiddle::Pinned` will prevent the object from moving: ```ruby class Foo A = "hi" # this is an embedded string A_pinner = Fiddle::Pinned.new(A) # :nodoc: some_c_function A # A can't move because of `Fiddle::Pinned` end ``` This is a similar strategy to what Graal uses: https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/PinnedObject.html#getObject-- * rename global to match exception name * Introduce generic Fiddle::Error and rearrange error classes Fiddle::Error is the generic exception base class for Fiddle exceptions. This commit introduces the class and rearranges Fiddle exceptions to inherit from it. https://github.com/ruby/fiddle/commit/ac52d00223
* [ruby/fiddle] Add support for specifying types by name as String or SymbolSutou Kouhei2020-11-181-13/+13
| | | | | | For example, :voidp equals to Fiddle::TYPE_VOID_P. https://github.com/ruby/fiddle/commit/3b4de54899
* [ruby/fiddle] Add TYPE_CONST_STRING and SIZEOF_CONST_STRING for "const char *"Sutou Kouhei2020-11-182-9/+27
| | | | | | | | Add rb_fiddle_ prefix to conversion functions.h to keep backward compatibility but value_to_generic() isn't safe for TYPE_CONST_STRING and not String src. Use rb_fiddle_value_to_generic() instead. https://github.com/ruby/fiddle/commit/0ffcaa39e5
* Workaroud for macOS Big Sur(11.0)Hiroshi SHIBATA2020-09-081-0/+5
|
* libSystem.dylib is also symlink. Use libSystem.B.dylibHiroshi SHIBATA2020-09-081-1/+1
|
* Use libSystem.dylib instead of libm.dylib and libc.dylibHiroshi SHIBATA2020-09-081-2/+1
| | | | Because macOS 11.0(Big Sur) was removed libc and libm from `/usr/lib`.
* Apply timeout-scale to test_nogvl_poll.Jun Aruga2020-07-301-1/+2
|
* [ruby/fiddle] support for very old libffiNobuyoshi Nakada2020-06-281-0/+3
| | | | | Define `Fiddle::TYPE_VARIADIC` only when `ffi_prep_cif_var` is available, otherwise skip the test for it.
* [ruby/fiddle] Support MSWIN (#43)Sutou Kouhei2020-06-271-1/+6
| | | | https://github.com/ruby/fiddle/commit/f16e7ff6e0
* [ruby/fiddle] test windows: use _snprintfSutou Kouhei2020-06-271-1/+6
| | | | https://github.com/ruby/fiddle/commit/aa261bdb9f
* [ruby/fiddle] Add support for variadic argumentsSutou Kouhei2020-06-272-1/+32
| | | | | | | | GitHub: fix GH-39 Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/6c4cb904dc
* [ruby/fiddle] Fixed typosNobuyoshi Nakada2020-06-261-0/+19
| | | | | | https://github.com/ruby/fiddle/commit/a09e66adf4 https://github.com/ruby/fiddle/commit/6cab9b45d6 https://github.com/ruby/fiddle/commit/ab72b19bed
* [ruby/fiddle] Improve documentation on how to correctly free memory and free ↵Chris Seaton2020-05-234-47/+94
| | | | | | memory in tests (#33) https://github.com/ruby/fiddle/commit/e59cfd708a
* [ruby/fiddle] Fix assignment to array within struct (#26)sinisterchipmunk2020-05-231-0/+14
| | | | | | * Allow access to a struct's underlying memory with `struct[offset, length]`. https://github.com/ruby/fiddle/commit/24083690a6
* [ruby/fiddle] Make array access override compatible with base class (#25)sinisterchipmunk2020-05-231-0/+22
| | | | | | | | | | | * Allow access to a struct's underlying memory with `struct[offset, length]`. * Make accessing a struct's underlying memory more convenient. * refactor memory access unit tests for improved clarity https://github.com/ruby/fiddle/commit/c082c81bb5
* `Dir.glob` always returns an arrayNobuyoshi Nakada2020-04-011-10/+5
| | | | | It is not needed to test itself, but the element should be tested instead.
* Fix helper to not assume glibcPaul Jordan2020-04-011-3/+16
|
* Fixed never-defined symbol nameNobuyoshi Nakada2020-03-041-1/+1
|
* pass appropriate libc path卜部昌平2020-01-241-0/+4
| | | | | | The same as https://github.com/ruby/ruby/pull/2686, but for musl libc. Musl is not named as libc.so.6 so the `ldd` hack implemented some lines below does not work.
* Fix "cannot find the function: strcpy()" error on arm32 on Travis CI. (#2686)Jun Aruga2019-12-051-1/+13
| | | | | | | | | | | This issue happened when `libc.so` and `libm.so` path were not found and `ldd ruby` command also failed to print the shared dependencies in `test/fiddle/helper.rb`. See https://travis-ci.org/ruby/ruby/jobs/611483288#L3018 /home/travis/build/ruby/ruby/build/.ext/common/fiddle/import.rb:299:in `import_function': cannot find the function: strcpy() (Fiddle::DLError) * Set libc6:armhf as a installing dependency explicitly. * Remove arm32 from allow_failures.
* More fixes for $SAFE/taint post mergingJeremy Evans2019-11-182-35/+0
|
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-182-0/+35
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Revert "[ruby/fiddle] Fix a failing test (#13)"Hiroshi SHIBATA2019-10-241-11/+0
| | | | This reverts commit 5ebb0d50f6560b35bc03deb79341a115c5f782ee.
* Revert "[ruby/fiddle] test: use env Hash"Hiroshi SHIBATA2019-10-241-13/+10
| | | | This reverts commit 4d844cbaed518743776594fa5ae33b86fe176ad1.
* [ruby/fiddle] Remove taint support (#21)Jeremy Evans2019-10-244-37/+1
| | | | | | | Ruby 2.7 deprecates taint and it no longer has an effect. The lack of taint support should not cause a problem in previous Ruby versions. https://github.com/ruby/fiddle/commit/18d6fb6915
* [ruby/fiddle] Use RbConfig::SIZEOF (#19)Nobuyoshi Nakada2019-10-241-2/+2
| | | | https://github.com/ruby/fiddle/commit/ea06b28db8
* [ruby/fiddle] test: use env HashSutou Kouhei2019-10-241-10/+13
| | | | https://github.com/ruby/fiddle/commit/a01a962342
* [ruby/fiddle] Fix a failing test (#13)Kenta Murata2019-10-241-0/+11
| | | | | | | | | | | | | | | | | | | | | * Fix a failing test This commit fixes the following failure: ``` 1) Failure: Fiddle::TestImport#test_no_message_with_debug [/Users/mrkn/src/github.com/ruby/fiddle/test/fiddle/test_import.rb:152]: 1. [2/2] Assertion for "stderr" | <[]> expected but was | <["Exception `NameError' at /Users/mrkn/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fiddle/import.rb:157 - uninitialized constant Fiddle::Function::STDCALL"]>. ``` * Stop using Bundler.with_clean_env * Clear existing Ruby environment variables on test_no_message_with_debug https://github.com/ruby/fiddle/commit/13133ddec8
* Make test-all and test-spec runnable on AndroidYusuke Endoh2019-09-091-0/+7
| | | | | | Calling some syscall functions such as Dir.chroot causes SIGSYS instead of EPERM on Android. This change skips all tests that stops the test-suite run.
* test/fiddle/test_function.rb: loosen timeoutk0kubun2018-12-231-1/+1
| | | | | | | | We're hitting `Expected |200 - 351| (151) to be <= 150.` in several places: https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1012/ruby-trunk/log/20181215T094505Z.fail.html.gz https://travis-ci.org/ruby/ruby/jobs/471483171 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_function.rb: loosen delta boundaryk0kubun2018-11-131-1/+1
| | | | | | | | | | | | | | | | | | On osx build https://travis-ci.org/ruby/ruby/jobs/454309945, ``` 1) Failure: Fiddle::TestFunction#test_nogvl_poll [/Users/travis/build/ruby/ruby/test/fiddle/test_function.rb:95]: slept amount of time. Expected |200 - 322| (122) to be <= 100. ``` but it succeeds on my macOS machine as is. So it seems that the boundary is just too strict and prone to random failure by overload. To make osx Travis build usable, let me loosen the delta requirement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_function.rb: try running test_nogvl_poll againk0kubun2018-08-181-4/+0
| | | | | | | | | According to some runs in mjit-test (make test-all RUN_OPTS="--jit-wait"), this test might not be the cause of its failure. So, let me try running this again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_function.rb: skip running testk0kubun2018-08-151-0/+4
| | | | | | | | | | | | | | that times out with test-all w/ --jit-wait. I'm running the following command on Wecker CI everyday: ``` make test-all TESTOPTS="--color=never --job-status=normal" RUN_OPTS="--disable-gems --jit-wait --jit-warnings" RUBY_FORCE_TEST_JIT=1 ``` By running yesterday's all commits, r64354 ran successfully but r64355 didn't. So the test should be fixed to run with --jit-wait at first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/fiddle/test_function.rb (test_nogvl_poll): stop timer hacknormal2018-08-141-0/+6
| | | | | | | | | | | | | | EINTR seems unavoidable in real programs (or MJIT), so maybe it's not worth dealing with. r64353 relies on POSIX timers to signal. Switching pipes and sockets to non-blocking by default would let us get rid of POSIX timers, timer pthread and this hack: https://bugs.ruby-lang.org/issues/14968 [ruby-core:88360] [Misc #14937] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_function.rb: fix messagesnobu2018-07-281-3/+14
| | | | | | | * test/fiddle/test_function.rb (test_nogvl_poll): fix messages as failed conditions, with errno description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* removed unusecd constantsnobu2018-07-121-4/+0
| | | | | | | | | | * ruby-runner.c (ruby_libm_func): removed as the following test actually doesn't need the path of libm. * test/fiddle/test_pointer.rb (Fiddle::TestPointer#test_free=): removed never used constants and instance variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fiddle/test_import.rb: fix warnings by rubygemsnobu2018-04-191-1/+1
| | | | | | [Bug #14686] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fiddle/import.rb: suppress warningnobu2018-04-191-0/+4
| | | | | | | * ext/fiddle/lib/fiddle/import.rb: suppress exception report when $DEBUG is enabled. [ruby-core:86536] [Bug #14686] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* long long is a C99ismshyouhei2018-02-172-3/+9
| | | | | | | | so SIZEOF_LONG_LONG is not always available. We have to check its defined?-ness before using. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `$SAFE` as a process global state. [Feature #14250]ko12017-12-282-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix test-all tests to avoid creating report_on_exception warningseregon2017-12-122-13/+15
| | | | | | | | | * The warnings are shown by Thread.report_on_exception defaulting to true. [Feature #14143] [ruby-core:83979] * Improves tests by narrowing down the scope where an exception is expected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e