summaryrefslogtreecommitdiff
path: root/bootstraptest/test_thread.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-12 13:01:38 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-12 13:01:38 +0000
commit6f5aaff73b2b4e17666308dde93e1ac4edb3927d (patch)
treed2045cf78eb8d6b894357491b6686fa8d23b740f /bootstraptest/test_thread.rb
parent2b66844f487574e2bcce1e3697883452d1f5d7fc (diff)
* thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add
deadlock detection. [ruby-dev:35044] * bootstraptest/test_thread.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest/test_thread.rb')
-rw-r--r--bootstraptest/test_thread.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
index 66b5363..d7ef671 100644
--- a/bootstraptest/test_thread.rb
+++ b/bootstraptest/test_thread.rb
@@ -302,3 +302,56 @@ assert_normal_exit %q{
assert_normal_exit %q{
Thread.new("foo", &Object.method(:class_eval)).join
}, '[ruby-dev:34128]'
+
+assert_equal 'ok', %q{
+ begin
+ Thread.new { Thread.stop }
+ Thread.stop
+ :ng
+ rescue Exception
+ :ok
+ end
+}
+
+assert_equal 'ok', %q{
+ begin
+ m1, m2 = Mutex.new, Mutex.new
+ Thread.new { m1.lock; sleep 1; m2.lock }
+ m2.lock; sleep 1; m1.lock
+ :ng
+ rescue Exception
+ :ok
+ end
+}
+
+assert_equal 'ok', %q{
+ m = Mutex.new
+ Thread.new { m.lock }; sleep 1; m.lock
+ :ok
+}
+
+assert_equal 'ok', %q{
+ m = Mutex.new
+ Thread.new { m.lock }; m.lock
+ :ok
+}
+
+assert_equal 'ok', %q{
+ m = Mutex.new
+ Thread.new { m.lock }.join; m.lock
+ :ok
+}
+
+assert_equal 'ok', %q{
+ m = Mutex.new
+ Thread.new { m.lock; sleep 2 }
+ sleep 1; m.lock
+ :ok
+}
+
+assert_equal 'ok', %q{
+ m = Mutex.new
+ Thread.new { m.lock; sleep 2; m.unlock }
+ sleep 1; m.lock
+ :ok
+}