This project is closed and read-only.
Backport #5335 » test_old_thread_select-timing-tweaks.patch
| test/-ext-/old_thread_select/test_old_thread_select.rb | ||
|---|---|---|
|
def test_old_select_read_timeout
|
||
|
with_pipe do |r, w|
|
||
|
t0 = Time.now
|
||
|
rc = IO.old_thread_select([r.fileno], nil, nil, 0.001)
|
||
|
rc = IO.old_thread_select([r.fileno], nil, nil, 0.01)
|
||
|
diff = Time.now - t0
|
||
|
assert_equal 0, rc
|
||
|
assert diff >= 0.001, "returned too early"
|
||
|
assert_operator diff, :>=, 0.004, "returned too early: diff=#{diff}"
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
bug5299 = '[ruby-core:39380]'
|
||
|
with_pipe do |r, w|
|
||
|
t0 = Time.now
|
||
|
rc = IO.old_thread_select(nil, nil, [r.fileno], 0.001)
|
||
|
rc = IO.old_thread_select(nil, nil, [r.fileno], 0.01)
|
||
|
diff = Time.now - t0
|
||
|
assert_equal 0, rc, bug5299
|
||
|
assert_operator diff, :>=, 0.001, "returned too early"
|
||
|
assert_operator diff, :>=, 0.004, "returned too early: diff=#{diff}"
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
rc = nil
|
||
|
t0 = Time.now
|
||
|
diff = nil
|
||
|
with_pipe do |r,w|
|
||
|
assert_nothing_raised do
|
||
|
t0 = Time.now
|
||
|
rc = IO.old_thread_select([r.fileno], nil, nil, 1)
|
||
|
diff = Time.now - t0
|
||
|
end
|
||
|
end
|
||
|
diff = Time.now - t0
|
||
|
assert diff >= 1.0, "interrupted or short wait"
|
||
|
assert_operator diff, :>=, 0.99, "interrupted or short wait: diff=#{diff}"
|
||
|
assert_equal 0, rc
|
||
|
assert_equal true, thr.value
|
||
|
assert received, "SIGINT not received"
|
||