summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
AgeCommit message (Collapse)Author
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-09-30test/ruby/test_io.rb: supress a "method redefined" warningYusuke Endoh
by explicitly removing the old definition.
2019-09-27Kernel#open may be redefinedNobuyoshi Nakada
2019-09-26Fix keyword argument sepration issues when IO#open calls #to_openJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2484
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-09-19DEBUG: cxxanyargsNobuyoshi Nakada
2019-09-19DEBUGNobuyoshi Nakada
2019-09-03Examine TestIO#test_select_exceptfds on Solaris with 1 byte dataNaohisa Goto
On Solaris, it seems that the select(3C) in this test works only when sending 1 byte out-of-band data, though I cannot investigate the cause. The behavior is observed on a Solaris 10 server in addition to Solaris 11 on which the test had been skipped.
2019-08-30Fix keyword argument separation warnings in testJeremy Evans
Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-30Move pread + pwrite tests out of RUBY_ENGINE blockCharles Oliver Nutter
These tests were guarded by a RUBY_ENGINE of "ruby" even though they test an official Ruby feature (pread/pwrite added in Ruby 2.5). This commit moves them to the top level of the test case so they will run on other implementations. Notes: Merged: https://github.com/ruby/ruby/pull/2412
2019-08-01Compact ensure clause and rename variables to fix alignmentKazuhiro NISHIYAMA
2019-07-31test/ruby/test_io.rb (test_binmode_pipe): close all pipes explicitlyYusuke Endoh
to suppress the leak checker.
2019-07-30Do not change IO.pipe encodings if encodings explicitly givenJeremy Evans
This commit makes it so that if the binmode option is given with any encoding arguments, the reader and writer IO objects are not set to binary encoding. Fixes [Bug #12989]
2019-07-30Passing `binmode: true` to `IO.pipe` should behave like `binmode`Aaron Patterson
When passing `binmode: true` to `IO.pipe`, it should behave the same way as calling `binmode` on each of the file handles. It should set the file to binmode *and* set the encoding to binary on the file. Before this commit, passing `binmode: true` to `IO.pipe` would make `binmode?` return `true`, but the file's encoding would remain the same as the default encoding. Passing `binmode: true` should make `binmode?` return `true` *and* set the encoding to binary.
2019-07-30Separate test_set_lineno_getsNobuyoshi Nakada
2019-07-25Fix errno at seeking socket/pipe on WindowsNobuyoshi Nakada
[Bug #12230]
2019-07-11Check exception flag as a bool [Bug #15987]Nobuyoshi Nakada
2019-06-11assert_cpu_usage_low with timeout scaleNobuyoshi Nakada
* test/lib/test/unit/assertions.rb (assert_cpu_usage_low): apply the timeout scale to measuring period. this assertion is very runtime environment dependent.
2019-04-18io.c: warn non-nil $,nobu
* array.c (rb_ary_join_m): warn use of non-nil $,. * io.c (rb_output_fs_setter): warn when set to non-nil value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-07io.c: chomp CR at the end of read buffernobu
* io.c (rb_io_getline_fast): chomp CR followed by LF but separated by the read buffer boundary. [ruby-core:91707] [Bug #15642] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-21test_io.rb: skip test on MJIT to prevent random failurek0kubun
like this: http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1636642 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-28test_io.rb: increase timeout for RubyCIk0kubun
to stabilize AIX powerpc CI https://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20181227T113302Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-30test/ruby/test_io.rb (test_recycled_fd_close): remove hacksnormal
I think I finally fixed the underlying bug in r65937 ("io.c (fptr_finalize_flush): close race leading to EBADF") I've run this test over 100000 times on a multicore system, now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-24io.c: wait on FD readability w/o GVL reacquisitionnormal
Since non-blocking I/O is the default after [Bug #14968], we will hit it more often and cause more acquisition/release of GVL to wait on single FD. This also lets us avoid touching the temporal string locking as much and lets us clean up some test changes made for [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22io + socket: make pipes and sockets nonblocking by defaultnormal
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are all capable of appearing to be "blocking" when presented with a file description with the O_NONBLOCK flag set; so there is little risk of incompatibility within Ruby-using programs. The biggest compatibility risk is when spawning external programs. As a result, stdin, stdout, and stderr are now always made blocking before exec-family calls. This change will make an event-oriented MJIT usable if it is waiting on pipes on POSIX_like platforms. It is ALSO necessary to take advantage of (proposed lightweight concurrency (aka "auto-Fiber") or any similar proposal for network concurrency: https://bugs.ruby-lang.org/issues/13618 Named-pipe (FIFO) are NOT yet non-blocking by default since they are rarely-used and may introduce compatibility problems and extra syscall overhead for a common path. Please revert this commit if there are problems and if I am afk since I am afk a lot, lately. [ruby-core:89950] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20Skip known MJIT random test failuresk0kubun
Let me silence this until I have time to work on them, and make the CI usable for testing other features. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-27test_io.rb: skip busy wait test againk0kubun
which I tried to avoid skipping this in r65311, but the test seems not working under some high load of ci.rvm.jp. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23test/lib/test/unit/assertions.rb: skip memory leak checkk0kubun
for all test cases on MJIT. In addition to those 2 tests, TestAutoload#test_no_leak newly failed and most of assert_no_memory_leak usages are likely to randomly fail. Let me just skip all of them but let's revisit this to check it properly later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22revisit more MJIT test skipsk0kubun
r65308 passed both trunk-mjit and trunk-mjit-wait CIs. MJIT copy job looks working fine. Then this commit skips 5 more tests. Some of them were skipped in a very early stage and may still need to be skipped, but I want to confirm them since they haven't been changed for a long time. And this prefers having inline information on `RubyVM::MJIT.enabled?`. This commit makes it easier to confirm whether there's suspicious test skip by RubyVM::MJIT.enabled? or not. After this commit, tentatively we're not skipping tests for MJIT other than `assert_no_memory_leak` ones. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22test/ruby/test_string.rb: skip test_crypt for MJIT againk0kubun
Partially reverting r65285. Actually this one is failing due to memory consumption on MJIT, so this seems not catching the bug of MJIT. test/ruby/test_io.rb: unify the skip message with it git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-15encoding.c: check external encodingnobu
* encoding.c (rb_enc_get_index): external encoding may not be Data object. [ruby-core:89016] [Bug #15122] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-29test/ruby/test_io.rb (test_select_leak): use handle_interruptnormal
Interrupt timing is tricky and it's possible the target thread is still stopped from the previous loop iteration. [ruby-core:88732] [Bug #15043] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-26test/ruby/test_io.rb (test_recycled_fd_close): Linux workaroundnormal
Arch Linux CI still seems to timeout on this test... Note, I can't reproduce the failures in these tests on a FreeBSD 11.1 VM while infinite-looping, even without the "th.join(0.001)". It doesn't seem related to the use of rb_wait_for_single_fd (r64529). cf. https://rubyci.org/logs/rubyci.s3.amazonaws.com/arch/ruby-trunk/log/20180826T090003Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-24test/ruby/test_io.rb (test_recycled_fd_close): use IO#read to avoid ppoll callnormal
IO#sysread calls rb_wait_for_single_fd for compatibility, and perhaps something is amiss with that (unrelated to timer-thread elimination) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-19test/ruby/test_io.rb (test_select_leak): quiet unused variable warningnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-13thread_pthread.c: eliminate timer thread by restructuring GVLnormal
This reverts commit 194a6a2c68e9c8a3536b24db18ceac87535a6051 (r64203). Race conditions which caused the original reversion will be fixed in the subsequent commit. [ruby-core:88360] [Misc #14937] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09add 'x' mode character for O_EXCLkazu
[Feature #11258] Patch by cremno (cremno phobia) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06thread_pthread.c: restore timer-thread for now :<normal
[ruby-core:88306] Revert "process.c: ensure th->interrupt lock is held when migrating" This reverts commit 5ca416bdf6b6785cb20f139c2c514eda005fe42f (r64201) Revert "process.c (rb_waitpid): reduce sigwait_fd bouncing" This reverts commit 217bdd776fbeea3bfd0b9324eefbfcec3b1ccb3e (r64200). Revert "test/ruby/test_thread.rb (test_thread_timer_and_interrupt): add timeouts" This reverts commit 9f395f11202fc3c7edbd76f5aa6ce1f8a1e752a9 (r64199). Revert "thread_pthread.c (native_sleep): reduce ppoll sleeps" This reverts commit b3aa256c4d43d3d7e9975ec18eb127f45f623c9b (r64193). Revert "thread.c (consume_communication_pipe): do not retry after short read" This reverts commit 291a82f748de56e65fac10edefc51ec7a54a82d4 (r64185). Revert "test/ruby/test_io.rb (test_race_gets_and_close): timeout each thread" This reverts commit 3dbd8d1f66537f968f0461ed8547460b3b1241b3 (r64184). Revert "thread_pthread.c (gvl_acquire_common): persist timeout across calls" This reverts commit 8c2ae6e3ed072b06fc3cbc34fa8a14b2acbb49d5 (r64165). Revert "test/ruby/test_io.rb (test_race_gets_and_close): use SIGABRT on timeout" This reverts commit 931cda4db8afd6b544a8d85a6815765a9c417213 (r64135). Revert "thread_pthread.c (gvl_yield): do ubf wakeups when uncontended" This reverts commit 508f00314f46c08b6e9b0141c01355d24954260c (r64133). Revert "thread_pthread.h (native_thread_data): split condvars on some platforms" This reverts commit a038bf238bd9a24bf1e1622f618a27db261fc91b (r64124). Revert "process.c (waitpid_nogvl): prevent conflicting use of sleep_cond" This reverts commit 7018acc946882f21d519af7c42ccf84b22a46b27 (r64117). Revert "thread_pthread.c (rb_sigwait_sleep): th may be 0 from MJIT" This reverts commit 56491afc7916fb24f5c4dc2c632fb93fa7063992 (r64116). Revert "thread*.c: waiting on sigwait_fd performs periodic ubf wakeups" This reverts commit ab47a57a46e70634d049e4da20a5441c7a14cdec (r64115). Revert "thread_pthread.c (gvl_destroy): make no-op on GVL bits" This reverts commit 95cae748171f4754b97f4ba54da2ae62a8d484fd (r64114). Revert "thread_pthread.c (rb_sigwait_sleep): fix uninitialized poll set in UBF case" This reverts commit 4514362948fdb914c6138b12d961d92e9c0fee6c (r64113). Revert "thread_pthread.c (rb_sigwait_sleep): re-fix [Bug #5343] harder" This reverts commit 26b8a70bb309c7a367b9134045508b5b5a580a77 (r64111). Revert "thread.c: move ppoll wrapper into thread_pthread.c" This reverts commit 3dc7727d22fecbc355597edda25d2a245bf55ba1 (r64110). Revert "thread.c: move ppoll wrapper before thread_pthread.c" This reverts commit 2fa1e2e3c3c5c4b3ce84730dee4bcbe9d81b8e35 (r64109). Revert "thread_pthread.c (ubf_select): refix [Bug #5343]" This reverts commit 4c1ab82f0623eca91a95d2a44053be22bbce48ad (r64108). Revert "thread_win32.c: suppress warnings by -Wsuggest-attribute" This reverts commit 6a9b63e39075c53870933fbac5c1065f7d22047c (r64159). Revert "thread_pthread: remove timer-thread by restructuring GVL" This reverts commit 708bfd21156828526fe72de2cedecfaca6647dc1 (r64107). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-04test/ruby/test_io.rb (test_select_leak): speedup and reduce memory usenormal
We can reuse the sub-thread and exception with Thread#raise to reproduce the old memory leak with less overhead. This allows us to to run more iterations and improve reliability of the actual test, particularly on platforms without USE_THREAD_CACHE. For glibc and jemalloc, also limit arena count to avoid inadvertant growth. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-04test/ruby/test_io.rb (test_race_gets_and_close): timeout each threadnormal
Still looking into CI failures on P895 (and seemingly no other boxes): http://ci.rvm.jp/results/trunk@P895/1190369 :< git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-31test/ruby/test_io.rb (test_race_gets_and_close): use SIGABRT on timeoutnormal
I can't reproduce the test failure and I'm still not sure what's wrong, but maybe we can get a core dump from P895: http://ci.rvm.jp/results/trunk@P895/1174672 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-25test/ruby/test_io.rb (test_select_leak): skip with MJITnormal
We need better ways to test for leaks :< git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-2360 sec is not enough at allusa
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-23increase timeout seconds.ko1
* test/ruby/test_io.rb (test_select_leak): increase timeout seconds to pass this test on a high-load machine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-21thread.c (do_select): fix leak on exceptionnormal
When do_select is interrupted and raise happens from RUBY_VM_CHECK_INTS_BLOCKING, the original FD sets we copied do not get freed, leading to a memory leak. Wrap up all the FD sets into a Ruby object to ensure the GC can release an allocations made for rb_fdset_t. This leak existed since Ruby 2.0.0 (r36430) [Bug #14929] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-11test/ruby/test_io.rb (test_copy_stream_to_duplex_io): join threadnormal
Don't leave runaway threads as it could affect other tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-11test/ruby/test_io.rb: skip garbage and CPU tests if multi-threadednormal
Threads should not be active during these tests, but maybe they are... ref: https://bugs.ruby-lang.org/issues/14906 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-27tests: increase timeouts and speedup some slow testsnormal
I'm still using the computer from 2005, so enabling MJIT makes some tests take longer. For test_deadlock_by_signal_at_forking I got it down to 135s to 89s by disabling RubyGems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-20test/ruby/test_io.rb: fix timing sensitive testnormal
For systems with sleepy timer thread disabled, the signal handler does not fire soon enough and we need to ensure the signal is received before we check its value. So use a self-pipe here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-08Remove unreachable breakkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e