From 070557afc4ca83876b951fe090806b59e3867ae5 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 6 Feb 2020 09:14:40 +0900 Subject: Distinguish signal and timeout [Bug #16608] --- test/monitor/test_monitor.rb | 2 +- test/ruby/test_thread_cv.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb index 3eceee7b2e..8ff6d006df 100644 --- a/test/monitor/test_monitor.rb +++ b/test/monitor/test_monitor.rb @@ -294,7 +294,7 @@ class TestMonitor < Test::Unit::TestCase @monitor.synchronize do assert_equal("foo", c) result3 = cond.wait(0.1) - assert_equal(true, result3) # wait always returns true in Ruby 1.9 + assert_equal(false, result3) assert_equal("foo", c) queue3.enq(nil) result4 = cond.wait diff --git a/test/ruby/test_thread_cv.rb b/test/ruby/test_thread_cv.rb index 5f19b85bc0..812c4221bc 100644 --- a/test/ruby/test_thread_cv.rb +++ b/test/ruby/test_thread_cv.rb @@ -16,6 +16,7 @@ class TestThreadConditionVariable < Test::Unit::TestCase mutex = Thread::Mutex.new condvar = Thread::ConditionVariable.new result = [] + woken = nil mutex.synchronize do t = Thread.new do mutex.synchronize do @@ -25,11 +26,12 @@ class TestThreadConditionVariable < Test::Unit::TestCase end result << 0 - condvar.wait(mutex) + woken = condvar.wait(mutex) result << 2 t.join end assert_equal([0, 1, 2], result) + assert(woken) end def test_condvar_wait_exception_handling @@ -140,11 +142,12 @@ INPUT condvar = Thread::ConditionVariable.new timeout = 0.3 locked = false + woken = true t0 = Time.now mutex.synchronize do begin - condvar.wait(mutex, timeout) + woken = condvar.wait(mutex, timeout) ensure locked = mutex.locked? end @@ -154,6 +157,7 @@ INPUT assert_operator(timeout*0.9, :<, t) assert(locked) + assert_nil(woken) end def test_condvar_nolock -- cgit v1.2.3