summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
AgeCommit message (Collapse)Author
2017-06-23Revert "Allow IO#reopen to take a block"glass
This reverts r59142. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-22Allow IO#reopen to take a blockglass
* io.c (rb_io_reopen): take a block and ensure the IO closed [Feature #2631] * test/ruby/test_io.rb: add a test * NEWS: add an entry for this change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06IO#close: do not enqueue redundant interrupts (take #2)normal
Enqueuing multiple errors for one event causes spurious errors down the line, as reported by Nikolay Vashchenko in https://bugs.ruby-lang.org/issues/13632 This should fix bad interactions with test_race_gets_and_close in test/ruby/test_io.rb since we ensure rb_notify_fd_close continues returning the busy flag after enqueuing the interrupt. Backporting changes to 2.4 and earlier releases will be more challenging... * thread.c (rb_notify_fd_close): do not enqueue multiple interrupts [ruby-core:81581] [Bug #13632] * test/ruby/test_io.rb (test_single_exception_on_close): new test based on script from Nikolay git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06re-revert r59020ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06revert r59023 because it contans unrelated developping codeko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06revert r59020 because it may fail some tests sometimes on some environment ↵ko1
(http://ci.rvm.jp/). This revert is to check the reason of failures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-06IO#close: do not enqueue redundant interruptsnormal
Enqueuing multiple errors for one event causes spurious errors down the line, as reported by Nikolay Vashchenko in https://bugs.ruby-lang.org/issues/13632 * thread.c (rb_notify_fd_close): do not enqueue multiple interrupts [ruby-core:81581] [Bug #13632] * test/ruby/test_io.rb (test_single_exception_on_close): new test based on script from Nikolay git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03test: attempt to reduce failures in assert_cpu_usage_lownormal
Try to make this test less fragile by taking into account the worst case kernel timing resolution. [ruby-core:81540] * test/lib/test/unit/assertions.rb (assert_cpu_usage_low): clamp measurement to minimum measurable time and warn about tests being too short to measure * test/ruby/test_io.rb (test_copy_stream_no_busy_wait): remove pct kwarg and rely on assert_cpu_usage_low defaults git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28test/ruby/test_io.rb: adjust CPU usage check to 10%normal
I miscalculated for r58934, since we sleep 100ms, and the worst possible case is 100 Hz in the kernel meaning we only have 10ms resolution. So, we need to increase our CPU percentage to >= 10% for this. This should be more than enough for our CI machines which have 300 Hz kernels [ruby-core:81429]: http://ci.rvm.jp/results/trunk-test@sasada-8core/1495942555 * test/ruby/test_io.rb (test_copy_stream_no_busy_wait): override default percentage git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-27test for IO.copy_stream CPU usage (r58534)normal
I'm likely to make similar mistakes in the future when working on Fiber auto-scheduling. Start adding assertions for existing code, first. * test/ruby/test_io.rb (test_copy_stream_no_busy_wait): added * test/lib/test/unit/assertions.rb (assert_cpu_usage_low): added git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-23skip on Solaris 11naruse
On Solaris 11, MSG_OOB is in readfds? http://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-trunk/log/20170523T152403Z.fail.html.gz http://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11s/ruby-trunk/log/20170523T152503Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19fix off-by-one in r58806normal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19test/ruby/test_io.rb: new test for IO.select exception setnormal
Ensure this rarely-used feature of IO.select continues to work properly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-16test/ruby/test_io.rb: use Thread.stop? to waitnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-16* test/ruby/test_io.rb (test_race_closed_stream): separate because it stopsusa
entire test process on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14sync certainly.ko1
* test/ruby/test_io.rb (test_race_closed_stream): awit for 'sleep' state. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-14more explicit synchronization.ko1
* test/ruby/test_io.rb (test_race_closed_stream): wait for blocking by r.gets. On some systems (for example, high load average systems) can't start Thread correctly and can't wait r.gets in invoked Thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03Fix arguments order of IO#pwritekazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-03Add IO#pread and IO#pwrite methodsnobu
These methods are useful for safe/concurrent file I/O in multi-thread/process environments and also fairly standard nowadays especially in systems supporting pthreads. Based on patches by Avseyev <sergey.avseyev@gmail.com> at [ruby-core:79290]. [Feature #4532] * configure.in: check for pwrite(2). pread() is already used internally for IO.copy_stream. * io.c: implement wrappers for pread(2) and pwrite(2) and expose them in IO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02Add class name to assert messageskazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-31test_io.rb: separate a testnobu
* test/ruby/test_io.rb (test_closed_stream_in_rescue): run in a separated process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-30io.c (rb_io_syswrite): avoid leaving garbage after writenormal
As with IO#write, IO#syswrite also generates garbage which can be harmful in hand-coded read-write loops. * io.c (swrite_arg, swrite_do, swrite_end): new (rb_io_syswrite): use new functions to cleanup garbage [ruby-core:78898] [Bug #13085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-30string.c (rb_str_tmp_frozen_release): release embedded stringsnormal
Handle the embedded case first, since we may have an embedded duplicate and non-embedded original string. * string.c (rb_str_tmp_frozen_release): handled embedded strings * test/ruby/test_io.rb (test_write_no_garbage): new test [ruby-core:78898] [Bug #13085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-30reduce iterations for slower machinesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-25io.c: close before waitnobu
* io.c (io_close_fptr): notify then close, and wait for other threads before free fptr. [ruby-core:79262] [Bug #13158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-24eval.c: copy special exceptionnobu
* eval.c (setup_exception): make unfrozen copy of special exception before setting up a cause. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-06test_io.rb: squiggly heredocnobu
* test/ruby/test_io.rb (test_threaded_flush): use squiggly here document to strip leading spaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-26io.c: fix race between read and closenobu
* io.c (io_fillbuf): fix race between read and close, in the case the IO gets closed before the reading thread achieve the lock. [ruby-core:78845] [Bug #13076] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-23Increase timeoutnaruse
http://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20161223T113301Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05chomp optionnobu
* io.c (extract_getline_opts): extract chomp option. [Feature #12553] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-15test_io.rb: use assert_not_predicatenobu
* test/ruby/test_io.rb (test_DATA_binmode): assert_not_predicate for more descriptive message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-15Add test of DATA.binmode?kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-13io.c: copy_stream to duplex IOnobu
* io.c (copy_stream_body): use IO to write to copy to duplex IO. http://twitter.com/knu/status/786505317974585344 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-06test_io.rb: split test_gets_rsnobu
* test/ruby/test_io.rb (test_gets_rs): split for each record separators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05test_io.rb: workaround for Dockernobu
* test/ruby/test_io.rb (test_ioctl_linux2): tty device may not work on Docker. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-07io.c: convert arguments just oncenobu
* io.c (rb_io_s_foreach, rb_io_s_readlines): convert arguments just once before reading, instead of conversions for each lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-21* test/ruby/test_io.rb: Skip test_readpartial_with_not_empty_buffer,duerst
test_read_buffer_error, test_read_unlocktmp_ensure, test_readpartial_unlocktmp_ensure, and test_sysread_unlocktmp_ensure on cygwin, because these tests repeatedly hang. This makes test_io.rb complete in finite time on cygwin. * ChangeLog: Fix test_in.rb -> test_io.rb (two instances). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-21* test/ruby/test_in.rb: Skip test_read_buffer_error on cygwin,duerst
because this test repeatedly hangs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-20* test/ruby/test_in.rb: Skip test_open_fifo_does_not_block_other_threadsduerst
on cygwin. Fifos seem to work okay in cygwin, but this test repeatedly hangs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-19test/ruby: suppress parser warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-30test_io.rb: test for rb_io_modestr_fmodenobu
* test/stringio/test_io.rb (test_flag): add assertion for error when text and binary mode are mixed. [ruby-dev:49465] [Feature #11921] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27IO#readpartial rejects bad argsnormal
Sometimes a sleepy developer will want to swap read_nonblock for readpartial forget to remove "exception: false" * io.c (io_getpartial): remove unused kwarg from template * test/ruby/test_io.rb (test_readpartial_bad_args): new [Bug #11885] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21* test/ruby/test_io.rb: handled rlimit value same as r52277hsbt
[Bug #11852][ruby-dev:49446] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16test/ruby/test_io.rb: fix spelling errorsnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53150 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-12-16test_io.rb: ignore not-implemented fadvicenobu
* test/ruby/test_io.rb (test_advise_pipe): ignore not-implemented fadvice(2) when it is present but not implemented, as IO#advice does nothing and raises no exceptions. [Feature #11806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11IO#advise should not raise Errno::ENOSYSnormal
As it is just a hint the kernel is free to ignore, IO#advise already succeeds when posix_fadvise is not available build time at all. Following that, if posix_fadvise was available at build time but not implemented in the running kernel, we should also ignore it. * io.c (do_io_advise): do not raise on ENOSYS * test/ruby/test_io.rb (test_advise): do not skip on Errno::ENOSYS (test_advise_pipe): ditto [ruby-core:72066] [Feature #11806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-11test_io.rb: fix IO#advise on aarch64-linuxnobu
* test/ruby/test_io.rb (test_advise, test_advise_pipe): fadvise on aarch64-linux returns ESYS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-26increase additional nfilesnaruse
On recent my environment, it must be more than 11. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-25io.c: try to_io firstnobu
* io.c (copy_stream_body): try to_io conversion before read, readpartial, and write methods. [ruby-dev:49008] [Bug #11199] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e