Skip to content

Commit 28a04de

Browse files
committed
ZJIT: Fix test_exit_tracing for Perfetto FXT output
1 parent 1265a40 commit 28a04de

2 files changed

Lines changed: 15 additions & 20 deletions

File tree

test/ruby/test_zjit.rb

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -383,25 +383,20 @@ def test
383383
end
384384

385385
def test_exit_tracing
386-
# This is a very basic smoke test. The StackProf format
387-
# this option generates is external to us.
388-
Dir.mktmpdir("zjit_test_exit_tracing") do |tmp_dir|
389-
assert_compiles('true', <<~RUBY, extra_args: ['-C', tmp_dir, '--zjit-trace-exits'])
390-
def test(object) = object.itself
391-
392-
# induce an exit just for good measure
393-
array = []
394-
test(array)
395-
test(array)
396-
def array.itself = :not_itself
397-
test(array)
398-
399-
RubyVM::ZJIT.exit_locations.is_a?(Hash)
400-
RUBY
401-
dump_files = Dir.glob('zjit_exits_*.dump', base: tmp_dir)
402-
assert_equal(1, dump_files.length)
403-
refute(File.empty?(File.join(tmp_dir, dump_files.first)))
404-
end
386+
# Smoke test: --zjit-trace-exits writes a Fuchsia trace (.fxt) file to /tmp
387+
assert_compiles('true', <<~RUBY, extra_args: ['--zjit-trace-exits'])
388+
def test(object) = object.itself
389+
390+
# induce an exit just for good measure
391+
array = []
392+
test(array)
393+
test(array)
394+
def array.itself = :not_itself
395+
test(array)
396+
397+
fxt_files = Dir.glob("/tmp/perfetto-\#{Process.pid}.fxt")
398+
fxt_files.length == 1 && !File.empty?(fxt_files.first)
399+
RUBY
405400
end
406401

407402
private

zjit/src/stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ pub fn zjit_alloc_bytes() -> usize {
976976
/// Fuchsia Trace Format (FXT) binary writer for --zjit-trace-exits.
977977
/// Produces .fxt files that can be opened directly in Perfetto UI.
978978
/// Uses the string table for deduplication of repeated reason/frame strings.
979-
/// See: https://fuchsia.dev/fuchsia-src/reference/tracing/trace-format
979+
/// See: <https://fuchsia.dev/fuchsia-src/reference/tracing/trace-format>
980980
pub struct PerfettoTracer {
981981
writer: std::io::BufWriter<std::fs::File>,
982982
start_time: std::time::Instant,

0 commit comments

Comments
 (0)