[前][次][番号順一覧][スレッド一覧]

ruby-changes:26053

From: kosaki <ko1@a...>
Date: Sat, 1 Dec 2012 17:29:06 +0900 (JST)
Subject: [ruby-changes:26053] kosaki:r38110 (trunk): * test/ruby/test_thread.rb (test_cv_wait_deadlock): enable

kosaki	2012-12-01 17:28:56 +0900 (Sat, 01 Dec 2012)

  New Revision: 38110

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38110

  Log:
    * test/ruby/test_thread.rb (test_cv_wait_deadlock): enable
      cv deadlock test.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_thread.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38109)
+++ ChangeLog	(revision 38110)
@@ -1,3 +1,8 @@
+Sat Dec  1 15:14:25 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* test/ruby/test_thread.rb (test_cv_wait_deadlock): enable
+	  cv deadlock test.
+
 Sat Dec  1 14:23:33 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* lib/thread.rb (ConditionVariable): use hash instead of array for
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 38109)
+++ test/ruby/test_thread.rb	(revision 38110)
@@ -197,19 +197,25 @@
     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
     threads = Array.new

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]