From 9f6a3d030682e9f99c77c2ef31881f9801c3979e Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sat, 18 Jul 2020 17:34:54 +1200 Subject: [PATCH] Add multi-threaded I/O test. --- test/fiber/test_io.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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