Files
mandy/tests/semantic/test_fixtures.py
ttd0x 695ae01d21 tests: value-level regression tests for RDNA2 -> SPIR-V pixel shaders
Add tests/semantic: translate two hand-written, branch-free pixel shaders
(ps_sdwa, ps_ops) and execute the resulting SPIR-V with a small strict
interpreter, asserting every mrt0 word against hand-derived expectations.
Catches wrong-value regressions (SDWA selects/sext, min3/max3, bfe_i32,
packed f16 FMA) that spirv-val cannot.

- Standard library only; no LLVM, SPIRV-Tools, GPU or game files.
- Interpreter rejects unmodelled constructs instead of approximating.
- Negative controls sabotage translated output; mutation tests sabotage a
  temporary copy of tools/ and require the matching test to fail.
- Fixtures are generated from runtime/test/shaders/*.asm.
- CI job semantic-tests (Windows + Ubuntu, Python 3.12), discovery limited
  to tests/semantic.
2026-11-21 18:27:51 +02:00

21 lines
719 B
Python

"""The committed fixtures are exactly what tests/semantic/regen_fixtures.py generates from the .asm sources."""
import os
import unittest
import regen_fixtures as rf
class FixtureTests(unittest.TestCase):
def test_fixtures_match_asm_sources(self):
for name in rf.SHADERS:
with self.subTest(name=name):
path = os.path.join(rf.FIXTURE_DIR, name + ".s")
self.assertTrue(os.path.isfile(path), "run tests/semantic/regen_fixtures.py")
with open(path, encoding="utf-8", newline="") as f:
have = f.read().replace("\r\n", "\n")
self.assertEqual(have, rf.render(name))
if __name__ == "__main__":
unittest.main()