summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEileen M. Uchitelle <[email protected]>2022-06-09 17:59:41 -0400
committerGitHub <[email protected]>2022-06-09 17:59:41 -0400
commite69e47f8d62456f85f70d52f736a23eab504f8b4 (patch)
tree5f7e19f07c69bed95c1fc7ce78c2a7916ae53fca
parentc2468fd88b977b1c0015fe7f49a822df1d07ea6f (diff)
Fix exit locations test (#5995)
I originally added the check for RubyVM::YJIT.trace_exit_locations_enabled? to fix errors when these tests run without the stats feature enabled. However I forgot that this will never be true when this test is booting, so nothing was running when the stats feature is turned on. Instead I've decided to make a new hash in the dump file and check if exit locations are enabled there. If they aren't enabled we return early to avoid checking for keys that won't exit in the dumped exit locations. I chose to add this additional enabled check because empty exit locations might not indicate that stats isn't enabled, it could mean the feature is entirely broken. I do want these tests to fail if stats are on and nothing was collected. Followup to #5970
Notes
Notes: Merged-By: maximecb <[email protected]>
-rw-r--r--test/ruby/test_yjit_exit_locations.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/ruby/test_yjit_exit_locations.rb b/test/ruby/test_yjit_exit_locations.rb
index d708bed5e9..7ad98cb109 100644
--- a/test/ruby/test_yjit_exit_locations.rb
+++ b/test/ruby/test_yjit_exit_locations.rb
@@ -8,7 +8,7 @@ require 'envutil'
require 'tmpdir'
require_relative '../lib/jit_support'
-return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? && RubyVM::YJIT.trace_exit_locations_enabled?
+return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
# Tests for YJIT with assertions on tracing exits
# insipired by the MJIT tests in test/ruby/test_yjit.rb
@@ -40,7 +40,10 @@ class TestYJITExitLocations < Test::Unit::TestCase
def assert_exit_locations(test_script)
write_results = <<~RUBY
- IO.open(3).write Marshal.dump(RubyVM::YJIT.exit_locations)
+ IO.open(3).write Marshal.dump({
+ enabled: RubyVM::YJIT.trace_exit_locations_enabled?,
+ exit_locations: RubyVM::YJIT.exit_locations
+ })
RUBY
script = <<~RUBY
@@ -51,7 +54,13 @@ class TestYJITExitLocations < Test::Unit::TestCase
#{write_results}
RUBY
- exit_locations = eval_with_jit(script)
+ run_script = eval_with_jit(script)
+ # If stats are disabled when configuring, --yjit-exit-locations
+ # can't be true. We don't want to check if exit_locations hash
+ # is not empty because that could indicate a bug in the exit
+ # locations collection.
+ return unless run_script[:enabled]
+ exit_locations = run_script[:exit_locations]
assert exit_locations.key?(:raw)
assert exit_locations.key?(:frames)