From e9bb3b9d305b438c89701a36e34de5fb1ee98991 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 16 Jan 2014 05:54:33 +0000 Subject: [PATCH] test_rinda.rb: timeout all thread * test/rinda/test_rinda.rb (test_do_reply): stop all threads and show backtraces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rinda/test_rinda.rb | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index 38909f90df..20aef9dc15 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -559,6 +559,15 @@ class TestRingServer < Test::Unit::TestCase end def test_do_reply + tl0 = Thread.list + tl = nil + th = Thread.new(Thread.current) do |mth| + sleep 1 + (tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)} + mth.raise(Timeout::Error) + end + tl0 << th + called = nil callback = proc { |ts| @@ -567,11 +576,6 @@ class TestRingServer < Test::Unit::TestCase callback = DRb::DRbObject.new callback - th = Thread.new(Thread.current) do |mth| - sleep 15 - mth.raise unless called - end - @ts.write [:lookup_ring, callback] @rs.do_reply @@ -585,6 +589,19 @@ class TestRingServer < Test::Unit::TestCase end assert_same @ts, called + rescue Timeout::Error => e + if tl + bt = e.backtrace + tl.each do |t| + begin + t.value + rescue Timeout::Error => e + bt.unshift("") + bt[0, 0] = e.backtrace + end + end + end + raise Timeout::Error, "timeout", bt ensure th.kill if th end