Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ skipped fixture. An `observed_without_pass` row appears in fixture evidence but
has no passing or skipped fixture. An `unobserved` row has no matching evidence
in the supplied measurement. A partial run can therefore list forms exercised
elsewhere. Check current fixtures and open PRs before choosing a form to work on.
Use the records directory of the preset that produced the JUnit file, for example
`out/build/release/form_coverage` for a `release` run. The tool exits with status
2 if that directory does not exist, and warns on stderr if none of its records
was written during the JUnit run, since no record-mode or shader form then counts.

Use original source, synthetic inputs or a public sample with its revision and license. Store local inputs in `game-files/` and generated output in `out/`. Keep game files, distribution links, SDK redistributables and dumps out of issues, PRs and Git. Remove personal paths and credentials from logs.

Expand Down
51 changes: 50 additions & 1 deletion tests/form_coverage_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,56 @@ def check_junit_errors():
assert expected in run.stderr, (name, run.stderr)


def check_records_errors():
"""A --records path that is not a directory is reported with exit status 2, because reading nothing from it
would count every record-mode and shader form as uncovered. A directory whose records all come from another
run is measured as before, with a warning; an empty directory (no recording test ran) is silent."""
import subprocess
tool = Path(fc.__file__)
start = datetime(2026, 11, 21, 21, 5, 21).timestamp() # CTest writes local time
junit_text = ('<testsuite time="1" timestamp="2026-11-21T21:05:21">'
'<testcase name="pixel_aot_warp" status="run"/></testsuite>')

def run(records, *extra):
return subprocess.run([sys.executable, "-B", str(tool), str(junit), "--records", str(records), *extra],
capture_output=True, text=True)

with tempfile.TemporaryDirectory() as tmp:
junit = Path(tmp) / "results.xml"
junit.write_text(junit_text, encoding="utf-8")
not_a_dir = Path(tmp) / "records.txt"
not_a_dir.write_text("s_endpgm\n", encoding="utf-8")
for path, expected in ((Path(tmp) / "missing", "records directory does not exist"),
(not_a_dir, "records path is not a directory")):
for extra in ((), ("--gaps", "gfx1013")):
result = run(path, *extra)
assert result.returncode == 2, (path, extra, result.returncode, result.stderr)
assert "Traceback" not in result.stderr, result.stderr
assert result.stderr == f"form_coverage: {path}: {expected}\n", result.stderr
assert result.stdout == "", result.stdout
records = Path(tmp) / "records"
records.mkdir()
empty = run(records)
assert empty.returncode == 0 and empty.stderr == "", (empty.returncode, empty.stderr)
assert "Shader translation records from this run: none" in empty.stdout, empty.stdout
record = records / "pixel_aot_warp.txt"
record.write_text("s_endpgm\n", encoding="utf-8")
os.utime(record, (start + 0.5, start + 0.5))
fresh = run(records)
assert fresh.returncode == 0 and fresh.stderr == "", (fresh.returncode, fresh.stderr)
assert "Shader translation records from this run: pixel_aot_warp" in fresh.stdout, fresh.stdout
# Negative control: the same record written an hour before the run is ignored, and the tool says so.
os.utime(record, (start - 3600, start - 3600))
for extra, header in (((), "Tests: 1 passed"), (("--gaps", "gfx1013"), "group\tform\tevidence\n")):
stale = run(records, *extra)
assert stale.returncode == 0, (extra, stale.returncode, stale.stderr)
assert stale.stderr == (f"form_coverage: {records}: none of the 1 records here was written during "
"this JUnit run, so no record-mode or shader form is counted\n"), stale.stderr
assert header in stale.stdout, stale.stdout


def check_gaps():
reference = {("VOP1", "v_a"), ("VOP3", "v_a_e64"), ("VOP3", "v_b_e64"), ("VOP1", "v_c")}
reference ={("VOP1", "v_a"), ("VOP3", "v_a_e64"), ("VOP3", "v_b_e64"), ("VOP1", "v_c")}
fixtures = {"passing": ({"v_a_e32"}, "pass"),
"skipping": ({"v_a_e32", "v_a_e64"}, "skip"),
"failing": ({"v_a_e64", "v_b_e64"}, "fail")}
Expand Down Expand Up @@ -1431,6 +1479,7 @@ def check_dpp_f16_arith_round_forms():
check_s_version_form()
check_parsing()
check_junit_errors()
check_records_errors()
check_gaps()
check_dashboard()
check_avx2_regs()
Expand Down
17 changes: 15 additions & 2 deletions tools/form_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
of each line of every program tools/pixel_aot.py lowered without an error, in the file CTest names
in FORM_COVERAGE_RECORD (<build>/form_coverage/<test>.txt). Programs a check expects to be rejected
raise before they are recorded. A record not written during the JUnit file's run is ignored, so a
record and a test status always come from the same run.
record and a test status always come from the same run. A --records path that is not a directory is an
error (exit 2); a directory whose records all come from another run is measured with a warning.
- Reference lists (denominators) live in docs/coverage/ and are produced by tools/form_reference.py.
Python standard library only.
"""
Expand Down Expand Up @@ -332,7 +333,19 @@ def main(argv):
except (OSError, ET.ParseError, ValueError) as error:
print(f"form_coverage: {args.junit}: {error}", file=sys.stderr)
return 2
m = measure(results, records=read_records(args.records, window), gaps_for=args.gaps)
# Reading nothing from a mistyped or wrong --records path would silently count every record-mode and shader
# form as uncovered, so a path that is not a directory is an error.
if not args.records.is_dir():
problem = "records path is not a directory" if args.records.exists() else "records directory does not exist"
print(f"form_coverage: {args.records}: {problem}", file=sys.stderr)
return 2
records = read_records(args.records, window)
stored = sum(1 for _ in args.records.glob("*.txt"))
if stored and not records:
# For example the records of another preset's build directory: valid, but nothing from this run counts.
print(f"form_coverage: {args.records}: none of the {stored} records here was written during this JUnit "
"run, so no record-mode or shader form is counted", file=sys.stderr)
m = measure(results, records=records, gaps_for=args.gaps)
if args.gaps:
gaps = m[args.gaps].pop("gaps")
if args.json:
Expand Down
Loading