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

* test/-ext-/old_thread_select/test_old_thread_select.rb:

select() with timeout may return early in old Linux kernels
  with 250 Hz tickrate and no dynticks, so skip everything older
  than 2.6.32 (which has long term support).
  And, Make the timing assertions consistently use assert_operator with
  timing difference in error message
  Patch by Eric Wong. [Bug #5335] [ruby-core:39618]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2011-09-19 09:47:27 +00:00
parent cb5f093e2a
commit d4db53a0e0
2 changed files with 22 additions and 7 deletions

View file

@ -1,3 +1,13 @@
Mon Sep 19 18:42:58 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* test/-ext-/old_thread_select/test_old_thread_select.rb:
select() with timeout may return early in old Linux kernels
with 250 Hz tickrate and no dynticks, so skip everything older
than 2.6.32 (which has long term support).
And, Make the timing assertions consistently use assert_operator with
timing difference in error message
Patch by Eric Wong. [Bug #5335] [ruby-core:39618]
Mon Sep 19 09:28:06 2011 Eric Hodel <drbrain@segment7.net> Mon Sep 19 09:28:06 2011 Eric Hodel <drbrain@segment7.net>
* test/openssl/test_ssl.rb (class OpenSSL): Test * test/openssl/test_ssl.rb (class OpenSSL): Test

View file

@ -3,6 +3,8 @@ require 'test/unit'
class TestOldThreadSelect < Test::Unit::TestCase class TestOldThreadSelect < Test::Unit::TestCase
require '-test-/old_thread_select/old_thread_select' require '-test-/old_thread_select/old_thread_select'
ANCIENT_LINUX = RUBY_PLATFORM =~ /linux/ && `uname -r`.chomp < '2.6.32'
def with_pipe def with_pipe
r, w = IO.pipe r, w = IO.pipe
begin begin
@ -19,9 +21,9 @@ class TestOldThreadSelect < Test::Unit::TestCase
rc = IO.old_thread_select([r.fileno], nil, nil, 0.001) rc = IO.old_thread_select([r.fileno], nil, nil, 0.001)
diff = Time.now - t0 diff = Time.now - t0
assert_equal 0, rc assert_equal 0, rc
assert_operator diff, :>=, 0.001, "returned too early" assert_operator diff, :>=, 0.001, "returned too early: diff=#{diff}"
end end
end end unless ANCIENT_LINUX
def test_old_select_error_timeout def test_old_select_error_timeout
bug5299 = '[ruby-core:39380]' bug5299 = '[ruby-core:39380]'
@ -30,9 +32,9 @@ class TestOldThreadSelect < Test::Unit::TestCase
rc = IO.old_thread_select(nil, nil, [r.fileno], 0.001) rc = IO.old_thread_select(nil, nil, [r.fileno], 0.001)
diff = Time.now - t0 diff = Time.now - t0
assert_equal 0, rc, bug5299 assert_equal 0, rc, bug5299
assert_operator diff, :>=, 0.001, "returned too early" assert_operator diff, :>=, 0.001, "returned too early: diff=#{diff}"
end end
end end unless ANCIENT_LINUX
def test_old_select_false_positive def test_old_select_false_positive
bug5306 = '[ruby-core:39435]' bug5306 = '[ruby-core:39435]'
@ -76,15 +78,18 @@ class TestOldThreadSelect < Test::Unit::TestCase
end end
rc = nil rc = nil
t0 = Time.now diff = nil
with_pipe do |r,w| with_pipe do |r,w|
assert_nothing_raised do assert_nothing_raised do
t0 = Time.now
rc = IO.old_thread_select([r.fileno], nil, nil, 1) rc = IO.old_thread_select([r.fileno], nil, nil, 1)
diff = Time.now - t0
end end
end end
diff = Time.now - t0 unless ANCIENT_LINUX
assert_operator diff, :>=, 1.0, "interrupted or short wait" assert_operator diff, :>=, 1, "interrupted or short wait: diff=#{diff}"
end
assert_equal 0, rc assert_equal 0, rc
assert_equal true, thr.value assert_equal true, thr.value
assert_not_equal false, received, "SIGINT not received" assert_not_equal false, received, "SIGINT not received"