1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2014-01-16 05:54:33 +00:00
parent 9a9f5f0f93
commit e9bb3b9d30

View file

@ -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