summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-01 08:28:56 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-01 08:28:56 +0000
commitafbbcd133ce38bf6749d8a431d08cf1c4bf732c7 (patch)
tree15706d0bef7914212ca96f6a3d46639a79dd293e /test
parent1f1db611b9860291454f38459f2aed33e0877d84 (diff)
* test/ruby/test_thread.rb (test_cv_wait_deadlock): enable
cv deadlock test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_thread.rb30
1 files changed, 18 insertions, 12 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index beee4c4be5..d01bec4800 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -197,18 +197,24 @@ class TestThread < Test::Unit::TestCase
assert_equal ["C1", "C1", "C1", "P1", "P2", "C2", "C2", "C2"], result
end
-# Hmm.. don't we have a way of catch fatal exception?
-#
-# def test_cv_wait_deadlock
-# mutex = Mutex.new
-# cv = ConditionVariable.new
-#
-# assert_raise(fatal) {
-# mutex.lock
-# cv.wait mutex
-# mutex.unlock
-# }
-# end
+ def test_condvar_wait_deadlock
+ assert_in_out_err([], <<-INPUT, ["No live threads left. Deadlock?"], [])
+ require "thread"
+
+ mutex = Mutex.new
+ cv = ConditionVariable.new
+
+ mesg = nil
+ begin
+ mutex.lock
+ cv.wait mutex
+ mutex.unlock
+ rescue Exception => e
+ mesg = e.message
+ end
+ print mesg
+INPUT
+ end
def test_condvar_wait_deadlock_2
nr_threads = 3