summaryrefslogtreecommitdiff
path: root/test/rinda
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-16 05:54:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-16 05:54:33 +0000
commite9bb3b9d305b438c89701a36e34de5fb1ee98991 (patch)
treee66c952bac22035d936aa4a3f95126a6c3095b2c /test/rinda
parent9a9f5f0f939c8abe43719a9815696cfae49b49c9 (diff)
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
Diffstat (limited to 'test/rinda')
-rw-r--r--test/rinda/test_rinda.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb
index 38909f90df4..20aef9dc15b 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