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

Split TestThread#test_join_limits into peaces

* test/ruby/test_thread.rb (TestThread#test_join_limit_*): Split
  TestThread#test_join_limits for investigating hang-up on Solaris.
  Each method tests only a single limit value.
  [ruby-core:87045] [Bug #14761]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ngoto 2018-05-15 14:31:47 +00:00
parent 6189f2263d
commit 80bf542a6c

View file

@ -2,6 +2,7 @@
# frozen_string_literal: false
require 'test/unit'
require "rbconfig/sizeof"
require "timeout"
class TestThread < Test::Unit::TestCase
class Thread < ::Thread
@ -228,19 +229,34 @@ class TestThread < Test::Unit::TestCase
t3.kill if t3
end
def test_join_limits
[ RbConfig::LIMITS['FIXNUM_MAX'], RbConfig::LIMITS['UINT64_MAX'],
Float::INFINITY ].each do |limit|
{ 'FIXNUM_MAX' => RbConfig::LIMITS['FIXNUM_MAX'],
'UINT64_MAX' => RbConfig::LIMITS['UINT64_MAX'],
'INFINITY' => Float::INFINITY
}.each do |name, limit|
define_method("test_join_limit_#{name}") do
t = Thread.new {}
assert_same t, t.join(limit), "limit=#{limit.inspect}"
end
t = Thread.new { sleep }
[ -1, -0.1, RbConfig::LIMITS['FIXNUM_MIN'], RbConfig::LIMITS['INT64_MIN'],
-Float::INFINITY
].each do |limit|
assert_nil t.join(limit), "limit=#{limit.inspect}"
end
{ 'minus_1' => -1,
'minus_0_1' => -0.1,
'FIXNUM_MIN' => RbConfig::LIMITS['FIXNUM_MIN'],
'INT64_MIN' => RbConfig::LIMITS['INT64_MIN'],
'minus_INFINITY' => -Float::INFINITY
}.each do |name, limit|
define_method("test_join_limit_negative_#{name}") do
t = Thread.new { sleep }
begin
assert_nothing_raised(Timeout::Error) do
Timeout.timeout(30) do
assert_nil t.join(limit), "limit=#{limit.inspect}"
end
end
ensure
t.kill
end
end
t.kill
end
def test_kill_main_thread