Codex
Replace the dataset with the current testing tree and the three UT docs.
d26f22a
Raw History Blame Contribute Delete
1.3 kB
"""Read one ``run_<TC>_<SEED>.log`` body.
Markers come from the env-gen checker and testbench templates and from the
generated Makefile's log grep. Text that matches none of them stays unset.
"""
from __future__ import annotations
import re
from dataclasses import dataclass
# checker.sv.tmpl, tb_top.sv.tmpl, and generate_makefile.py.
_FUNCTIONAL = re.compile(
r"\[SB\] mismatch|\[SB\] unexpected output|\[SVA\]|\[EOC\] scoreboard|"
r"\[SB_SUMMARY\][^\n]*(?:failed=[1-9]\d*|residue=[1-9]\d*)"
)
_CLEAN = re.compile(r"\*\*\* PASS|\[SB_SUMMARY\][^\n]*failed=0\b[^\n]*residue=0\b|\[WATCHDOG\]")
@dataclass(frozen=True)
class RunLogSummary:
"""Whether one run log shows a functional failure.
``None`` means the log could not be judged. It is not a miss.
"""
functional_hit: bool | None
def read_run_log(text: str) -> RunLogSummary:
"""Return whether ``text`` shows a scoreboard or assertion failure."""
if not isinstance(text, str):
raise TypeError("text must be a string")
if not text.strip():
return RunLogSummary(functional_hit=None)
if _FUNCTIONAL.search(text):
return RunLogSummary(functional_hit=True)
if _CLEAN.search(text):
return RunLogSummary(functional_hit=False)
return RunLogSummary(functional_hit=None)