Skip to content

Commit

Permalink
Scale the time to wait native threads to run hook
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jun 19, 2022
1 parent 4aebbf4 commit da362fe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/-ext-/thread/test_instrumentation_api.rb
@@ -1,11 +1,15 @@
# frozen_string_literal: false
require 'envutil'

class TestThreadInstrumentation < Test::Unit::TestCase
def setup
pend("TODO: No windows support yet") if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
end

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
require '-test-/thread/instrumentation'
Bug::ThreadInstrumentation.reset_counters
Expand All @@ -19,7 +23,7 @@ def test_thread_instrumentation
assert_predicate c,:nonzero?, "Call counters: #{counters.inspect}"
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
ensure
Bug::ThreadInstrumentation::unregister_callback
Expand All @@ -39,7 +43,7 @@ def test_thread_instrumentation_fork_safe
Bug::ThreadInstrumentation.reset_counters
threads = threaded_cpu_work
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.close
exit!(0)
Expand Down

0 comments on commit da362fe

Please sign in to comment.