diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-07-18 17:34:54 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2020-07-20 13:20:58 +1200 |
commit | 9f6a3d030682e9f99c77c2ef31881f9801c3979e (patch) | |
tree | 6922139d365ea34d8c865dcd068ad3366cc8d0e8 /test/fiber/test_io.rb | |
parent | e6e9cef06e9023a80991518297d9f2c0c12488ce (diff) | |
download | ruby-9f6a3d030682e9f99c77c2ef31881f9801c3979e.tar.gz |
Add multi-threaded I/O test.
Diffstat (limited to 'test/fiber/test_io.rb')
-rw-r--r-- | test/fiber/test_io.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index bf200061d8..90ac4aa5cd 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -39,4 +39,27 @@ class TestFiberIO < Test::Unit::TestCase assert_predicate(i, :closed?) assert_predicate(o, :closed?) end + + def test_heavy_read + skip unless defined?(UNIXSocket) + + 16.times.map do + thread = Thread.new do + i, o = UNIXSocket.pair + + scheduler = Scheduler.new + Thread.current.scheduler = scheduler + + Fiber do + message = i.read(20) + i.close + end + + Fiber do + o.write("Hello World") + o.close + end + end + end.each(&:join) + end end |