From 2abf47bff9a9780f8640a7d89caef9915cbe6bd0 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 12 Apr 2015 05:22:28 +0000 Subject: Test fifo without sleep. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 11ef5252e6..a06fce8eb9 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3182,12 +3182,18 @@ End mkcdtmpdir { assert(system("mkfifo", "fifo"), "mkfifo fails") assert_separately([], <<-'EOS') - t = Thread.new { - open("fifo") {} + t1 = Thread.new { + open("fifo", "r") {|r| + r.read + } } - sleep 0.1 until t.status == "sleep" - sleep 0.1 - assert(true) + t2 = Thread.new { + open("fifo", "w") {|w| + w.write "foo" + } + } + t1_value, _ = assert_join_threads([t1, t2]) + assert_equal("foo", t1_value) EOS } end if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM -- cgit v1.2.3