mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 22:48:50 +00:00
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.
21 lines
719 B
Python
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()
|