summaryrefslogtreecommitdiff
path: root/test/fiddle
AgeCommit message (Collapse)Author
2020-06-28[ruby/fiddle] support for very old libffiNobuyoshi Nakada
Define `Fiddle::TYPE_VARIADIC` only when `ffi_prep_cif_var` is available, otherwise skip the test for it.
2020-06-27[ruby/fiddle] Support MSWIN (#43)Sutou Kouhei
https://github.com/ruby/fiddle/commit/f16e7ff6e0 Notes: Merged: https://github.com/ruby/ruby/pull/3265
2020-06-27[ruby/fiddle] test windows: use _snprintfSutou Kouhei
https://github.com/ruby/fiddle/commit/aa261bdb9f Notes: Merged: https://github.com/ruby/ruby/pull/3265
2020-06-27[ruby/fiddle] Add support for variadic argumentsSutou Kouhei
GitHub: fix GH-39 Reported by kojix2. Thanks!!! https://github.com/ruby/fiddle/commit/6c4cb904dc Notes: Merged: https://github.com/ruby/ruby/pull/3265
2020-06-26[ruby/fiddle] Fixed typosNobuyoshi Nakada
https://github.com/ruby/fiddle/commit/a09e66adf4 https://github.com/ruby/fiddle/commit/6cab9b45d6 https://github.com/ruby/fiddle/commit/ab72b19bed
2020-05-23[ruby/fiddle] Improve documentation on how to correctly free memory and free ↵Chris Seaton
memory in tests (#33) https://github.com/ruby/fiddle/commit/e59cfd708a
2020-05-23[ruby/fiddle] Fix assignment to array within struct (#26)sinisterchipmunk
* Allow access to a struct's underlying memory with `struct[offset, length]`. https://github.com/ruby/fiddle/commit/24083690a6 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-05-23[ruby/fiddle] Make array access override compatible with base class (#25)sinisterchipmunk
* 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 Notes: Merged: https://github.com/ruby/ruby/pull/3068
2020-04-01`Dir.glob` always returns an arrayNobuyoshi Nakada
It is not needed to test itself, but the element should be tested instead.
2020-04-01Fix helper to not assume glibcPaul Jordan
Notes: Merged: https://github.com/ruby/ruby/pull/2995
2020-03-04Fixed never-defined symbol nameNobuyoshi Nakada
2020-01-24pass appropriate libc path卜部昌平
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.
2019-12-05Fix "cannot find the function: strcpy()" error on arm32 on Travis CI. (#2686)Jun Aruga
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.
2019-11-18More fixes for $SAFE/taint post mergingJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
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. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-10-24Revert "[ruby/fiddle] Fix a failing test (#13)"Hiroshi SHIBATA
This reverts commit 5ebb0d50f6560b35bc03deb79341a115c5f782ee. Notes: Merged: https://github.com/ruby/ruby/pull/2603
2019-10-24Revert "[ruby/fiddle] test: use env Hash"Hiroshi SHIBATA
This reverts commit 4d844cbaed518743776594fa5ae33b86fe176ad1. Notes: Merged: https://github.com/ruby/ruby/pull/2603
2019-10-24[ruby/fiddle] Remove taint support (#21)Jeremy Evans
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
2019-10-24[ruby/fiddle] Use RbConfig::SIZEOF (#19)Nobuyoshi Nakada
https://github.com/ruby/fiddle/commit/ea06b28db8
2019-10-24[ruby/fiddle] test: use env HashSutou Kouhei
https://github.com/ruby/fiddle/commit/a01a962342
2019-10-24[ruby/fiddle] Fix a failing test (#13)Kenta Murata
* 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
2019-09-09Make test-all and test-spec runnable on AndroidYusuke Endoh
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.
2018-12-23test/fiddle/test_function.rb: loosen timeoutk0kubun
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
2018-11-13test_function.rb: loosen delta boundaryk0kubun
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
2018-08-18test_function.rb: try running test_nogvl_poll againk0kubun
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
2018-08-15test_function.rb: skip running testk0kubun
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
2018-08-14test/fiddle/test_function.rb (test_nogvl_poll): stop timer hacknormal
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
2018-07-28test_function.rb: fix messagesnobu
* 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
2018-07-12removed unusecd constantsnobu
* 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
2018-04-19fiddle/test_import.rb: fix warnings by rubygemsnobu
[Bug #14686] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19fiddle/import.rb: suppress warningnobu
* 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
2018-02-17long long is a C99ismshyouhei
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
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* 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
2017-12-12Fix test-all tests to avoid creating report_on_exception warningseregon
* 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
2017-09-12Use mutable strings for mutation tests.ko1
* test/fiddle/test_func.rb (test_string): this test break String buffer by `strcpy` ("000" -> "123"). However, the string literal "000" with `frozen_string_literal: true` returns a string object from frozen string pool. So that after this test "000" from fstring pool becomes "123" (modified string). 'test/date/' uses "000" (as fstring) and tests are fails (we could check with `make test-all TESTS='fiddle date'`). * test/fiddle/test_function.rb: ditto. * test/fiddle/test_import.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-12Merge fiddle-1.0.0.beta2 from upstream.hsbt
* ext/fiddle/closure.c: use directly declaration for standalone gem without internal.h. * Specify frozen string literal is true. * Update gemspec configuration for release version. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-13Use Test::Unit::TestCase instead of MiniTest::Unit::TestCase. Becausehsbt
tests of fiddle already used customized assertions of ruby core. * test/fiddle/helper.rb: Use Test::Unit::TestCase for base class of testcase. * test/fiddle/test_*.rb: Use assert_raise instead of assert_raises. Remove needless includes for Test::Unit::Assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-11test/fiddle/helper: remove special case for x86_64-linuxnormal
RUBY_PLATFORM is "x86_64-linux" on a 32-bit (x86) Ruby built and running on a 64-bit Linux kernel. I also have a /lib64 directory nowadays because I just installed multi-arch support in userspace. So, fall back to loading based in the size of a packed "unsigned long" type instead of special-casing. Tested with both x86 and x86_64 userspace on 64-bit Linux kernel, as well as x86 with a 32-bit Linux kernel. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-14Removed the obstacle to running test-all with VC14.usa
* test/fiddle/test_import.rb (LIBC.fprintf): VC14's `fprintf` is very distinct name, then, just ignore this test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-01* test/fiddle/test_pointer.rb (test_to_str, test_to_s, test_aref_aset):ngoto
Attempt to use independent strings for destructive tests that directly modify values on memory by using Fiddle::Pointer. [Bug #12537] [ruby-dev:49700] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-16* test_handle.rb: refine test_fallback_to_ansinobu
* test/fiddle/test_handle.rb (test_fallback_to_ansi): ensure that the fallback result equals to ANSI version. [ruby-core:75494] [Bug #12377] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-16configure.in: revert macro namesnobu
* configure.in (FUNC_STDCALL, FUNC_CDECL, FUNC_FASTCALL): set macro names explicitly to the old names, which are accidentally changed at r54985, for backward compatibilities. fiddle also depends on these names to fallback to ANSI names. [ruby-core:75494] [Bug #12377] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16* ext/fiddle/handle.c: check tainted string arguments.nagachika
Patch provided by tenderlove and nobu. * test/fiddle/test_handle.rb (class TestHandle): add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-23fiddle: release GVL for ffi_callnormal
Some external functions I wish to call may take a long time and unnecessarily block other threads. This may lead to performance regressions for fast functions as releasing/acquiring the GVL is not cheap, but can improve performance for long-running functions in multi-threaded applications. This also means we must reacquire the GVL when calling Ruby-defined callbacks for Fiddle::Closure, meaning we must detect whether the current thread has the GVL by exporting ruby_thread_has_gvl_p in internal.h * ext/fiddle/function.c (struct nogvl_ffi_call_args): new struct for GVL release (nogvl_ffi_call): new function (function_call): adjust for GVL release [ruby-core:71642] [Feature #11607] * ext/fiddle/closure.c (struct callback_args): new struct for GVL acquire (with_gvl_callback): adjusted original callback function (callback): wrapper for conditional GVL acquire * ext/fiddle/depend: add dependencies * ext/fiddle/extconf.rb: include top_srcdir for internal.h * internal.h (ruby_thread_has_gvl_p): expose for fiddle * vm_core.h (ruby_thread_has_gvl_p): moved to internal.h * test/fiddle/test_function.rb (test_nogvl_poll): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-21fix r52690naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-21Visual C++ 14 (2015) uses ucrtbase.dll as c runtimenaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30test/fiddle: revert r52384 partiallynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30use assert_raisenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18* include/ruby/ruby.h: $SAFE=2 is now obsolete.hsbt
* dir.c, ext/fiddle/handle.c, ext/socket/basicsocket.c, file.c gc.c, io.c, process.c, safe.c, signal.c, win32/file.c: removed code for $SAFE=2 * test/erb/test_erb.rb, test/fiddle/test_handle.rb test/ruby/test_env.rb: removed tests for $SAFE=2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e