Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better test
  • Loading branch information
maurycy committed Jul 11, 2026
commit 26109d0e44a0b038cf675fcb7fe0cf0db937a5ba
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,15 @@ def write_sample(self, stack_frames, timestamp_us):
# keeps the samples collected before the limit was hit.
collector._writer = real_writer
collector.export(None)

with open(filename, "rb") as f:
header = f.read(32)
magic, version = struct.unpack_from("=II", header, 0)
self.assertEqual(magic, 0x54414348) # "TACH"
self.assertEqual(version, 1)
(sample_count,) = struct.unpack_from("=I", header, 28)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

total_samples is a u64 in the header (HDR_SIZE_SAMPLES is 8), so "=I" here only reads half of it. On big-endian (the s390x buildbots) this reads the high word and the assert will fail. Can we read 64 bytes and unpack with "=Q"? btw TestBinaryFormatValidation below already has HDR_OFF_SAMPLES = 28, maybe we can reuse it.

@maurycy maurycy Aug 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pablogsal Definitely. Thank you for catching this. Sorry for not updating the PR immediately after merging #153425.

Changed to =Q and moved HDR_OFF_SAMPLES, and other consts, to BinaryFormatTestBase in 1231afe

I ack there's still #152892 (comment) pending

Comment thread
maurycy marked this conversation as resolved.
Outdated
self.assertEqual(sample_count, 3)

reader_collector = RawCollector()
with BinaryReader(filename) as reader:
self.assertEqual(reader.replay_samples(reader_collector), 3)
Expand Down