1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/-ext-/gvl/test_ubf_async_safe.rb
Nobuyoshi Nakada 590dc06e38 Get rid of defining methods for tests in core classes
Not to interfere in other tests.
2021-01-09 22:38:06 +09:00

20 lines
627 B
Ruby

# frozen_string_literal: true
class TestUbfAsyncSafe < Test::Unit::TestCase
def test_ubf_async_safe
skip 'need fork for single-threaded test' unless Process.respond_to?(:fork)
IO.pipe do |r, w|
pid = fork do
require '-test-/gvl/call_without_gvl'
r.close
trap(:INT) { exit!(0) }
Bug::Thread.ubf_async_safe(w.fileno)
exit!(1)
end
w.close
assert IO.select([r], nil, nil, 30), 'child did not become ready'
Process.kill(:INT, pid)
_, st = Process.waitpid2(pid)
assert_predicate st, :success?, ':INT signal triggered exit'
end
end
end