mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
- tools/decode_original_pt_bounded.py: validate --max-lines/--max-errors >= 1, guard perf child teardown in try/finally, report missing perf cleanly, propagate non-zero perf exit codes when not stopped by a limit, and wrap in main(). - tools/check_uvm_620_exports.py: fail cleanly on missing module files or empty undefined nvUvmInterface* symbol set (preventing false green on stripped/wrong binaries), parse CLI via argparse, and wrap in main(). - tools/check_mmu_oracle.py and tools/timer-alarm-vectors.py: replace -O-elidable assert checks with explicit SystemExit errors and wrap in main(). - tools/check_compat_layout.py: resolve NVIDIA 580.178.04 include dirs via NV_RS_ANALYSIS_ROOT / NV_RS_KERNEL_SRC / OPEN_GPU_ROOT / /usr/src/nvidia-580.178.04 instead of hardcoding /home/geodd, replace -O-elidable asserts, and wrap in main(). - tools/check_original_live_init.py: close timestamped-record-dump.txt with a context manager and wrap in main(). - tests/offline/test_oracle_check_and_pt_decoder_tools.py: offline unit tests verified under python3 -O.
67 lines
2.2 KiB
Python
67 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate or verify Rust timer-alarm test vectors from reports/timer-alarm-original.json."""
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
|
|
R = Path(__file__).resolve().parents[1]
|
|
TAGS = {"flag": 0, "access": 1, "write": 2, "time": 3, "pending": 4, "diagnostic": 5}
|
|
KINDS = {"alarm": 0, "schedule": 1, "countdown": 2}
|
|
POLICIES = {"valid": 0, "not_loaded": 1, "inaccessible": 2}
|
|
|
|
|
|
def render_vectors(data):
|
|
lines = [
|
|
"use super::Vector;",
|
|
"// Actual original016384/059642/059655 instruction outputs; not Rust-generated expectations.",
|
|
"#[rustfmt::skip]",
|
|
"pub(super) const VECTORS: &[Vector] = &[",
|
|
]
|
|
for row in data["cases"]:
|
|
c = row["input"]
|
|
events = ",".join(
|
|
"&[" + ",".join(map(str, [TAGS[e[0]], *e[1:]])) + "]" for e in row["events"]
|
|
)
|
|
values = ",".join(map(str, c["times"]))
|
|
pending = ",".join(map(str, c["pending"]))
|
|
status = "None" if row["status"] is None else f"Some({row['status']})"
|
|
lines.append(
|
|
"Vector {kind:%d,deadline:%d,flags:%d,gpu908:%d,disabled:%d,countdown:%d,policy:%d,"
|
|
"times:&[%s],pending:&[%s],events:&[%s],status:%s},"
|
|
% (
|
|
KINDS[c["kind"]],
|
|
c["deadline"],
|
|
c["flags"],
|
|
c["gpu908"],
|
|
c["disabled"],
|
|
c["countdown"],
|
|
POLICIES[c["policy"]],
|
|
values,
|
|
pending,
|
|
events,
|
|
status,
|
|
)
|
|
)
|
|
lines.append("];")
|
|
return "\n".join(lines) + "\n"
|
|
|
|
|
|
def main(argv=None):
|
|
p = argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument("--check", action="store_true")
|
|
a = p.parse_args(argv)
|
|
data = json.loads((R / "reports/timer-alarm-original.json").read_text())
|
|
rendered = render_vectors(data)
|
|
dest = R / "tests/timer-alarm/vectors.rs"
|
|
if a.check:
|
|
if not dest.is_file() or dest.read_text() != rendered:
|
|
raise SystemExit("Original alarm Rust vectors drift")
|
|
else:
|
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
dest.write_text(rendered)
|
|
print(len(data["cases"]), "independent original vectors retained")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|