Files
foxhound/scripts/test_faultbook.py
Yoshi-233 5b6187df28 Report take-to-fault intervals in performance-counter order
Port of https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3587 to readmet3xt-lab/foxhound. The regression runs independently of the NVIDIA-only test suite.
2026-11-30 10:43:18 +08:00

29 lines
968 B
Python

"""Regression tests for the fault-book report, with no game files."""
from contextlib import redirect_stdout
from io import StringIO
from pathlib import Path
from tempfile import TemporaryDirectory
import unittest
from faultbook import RECORD, book
class FaultBookTest(unittest.TestCase):
def test_take_and_fault_use_counter_order_across_threads(self):
with TemporaryDirectory() as temp:
path = Path(temp) / "capture.bin"
path.write_bytes(b"".join([
RECORD.pack(200, 7, 0, 0, 2, 1), # fault appended first
RECORD.pack(100, 7, 8, 0, 1, 2), # earlier take on another thread
RECORD.pack(300, 0, 0, 0, 1, 0),
]))
out = StringIO()
with redirect_stdout(out):
book(path, 1_000_000)
self.assertIn("from a block's taking to its next fault (us): n 1, p50 100.0", out.getvalue())
if __name__ == "__main__":
unittest.main()