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

Scale the time to wait native threads to run hook

This commit is contained in:
Nobuyoshi Nakada 2022-06-19 23:33:26 +09:00
parent 4aebbf44e9
commit da362fee59
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -1,4 +1,6 @@
# frozen_string_literal: false # frozen_string_literal: false
require 'envutil'
class TestThreadInstrumentation < Test::Unit::TestCase class TestThreadInstrumentation < Test::Unit::TestCase
def setup def setup
pend("TODO: No windows support yet") if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM pend("TODO: No windows support yet") if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
@ -6,6 +8,8 @@ class TestThreadInstrumentation < Test::Unit::TestCase
THREADS_COUNT = 3 THREADS_COUNT = 3
Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook = EnvUtil.apply_timeout_scale(0.01)
def test_thread_instrumentation def test_thread_instrumentation
require '-test-/thread/instrumentation' require '-test-/thread/instrumentation'
Bug::ThreadInstrumentation.reset_counters Bug::ThreadInstrumentation.reset_counters
@ -19,7 +23,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase
assert_predicate c,:nonzero?, "Call counters: #{counters.inspect}" assert_predicate c,:nonzero?, "Call counters: #{counters.inspect}"
end end
sleep 0.01 # Give more time to the native threads to execute their EXIT hook sleep(Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook)
assert_equal counters.first, counters.last # exited as many times as we entered assert_equal counters.first, counters.last # exited as many times as we entered
ensure ensure
Bug::ThreadInstrumentation::unregister_callback Bug::ThreadInstrumentation::unregister_callback
@ -39,7 +43,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase
Bug::ThreadInstrumentation.reset_counters Bug::ThreadInstrumentation.reset_counters
threads = threaded_cpu_work threads = threaded_cpu_work
write_pipe.write(Marshal.dump(threads.map(&:status))) write_pipe.write(Marshal.dump(threads.map(&:status)))
sleep 0.01 # Give more time to the native threads to execute their EXIT hook sleep(Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook)
write_pipe.write(Marshal.dump(Bug::ThreadInstrumentation.counters)) write_pipe.write(Marshal.dump(Bug::ThreadInstrumentation.counters))
write_pipe.close write_pipe.close
exit!(0) exit!(0)