diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/gvl/test_ubf_async_safe.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/-ext-/gvl/test_ubf_async_safe.rb b/test/-ext-/gvl/test_ubf_async_safe.rb new file mode 100644 index 0000000000..85c4a7d38e --- /dev/null +++ b/test/-ext-/gvl/test_ubf_async_safe.rb @@ -0,0 +1,20 @@ +# 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) } + Thread.current.__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 |