mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:08:40 +00:00
Each process added its output hash to `hashes` before a later process of the same configuration could fail. The failed configuration got no row, but its partial hashes stayed, so the "every configuration ran" check passed, it was compared as if it had run, and the script could print "emulated output equals the reference" and exit 0. A reference that failed after its first process was used as the reference all the same. Hashes are now kept only for a configuration whose every process ran. The test replaces the builds and the GPU runs with stubs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""bench_wave64.py: a configuration that fails after its first process is a failure, not a configuration that ran.
|
|
The builds and GPU runs are replaced by stubs, so this needs no GPU, LLVM or Vulkan SDK."""
|
|
import contextlib
|
|
import io
|
|
import os
|
|
import sys
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
|
import bench_wave64 # noqa: E402
|
|
|
|
|
|
def bench(fail):
|
|
"""Run main() with 2 processes per configuration; `fail` maps a configuration name to the process that fails."""
|
|
calls = {}
|
|
|
|
def run(tools, spv, groups, reps, driver, emulate):
|
|
name = next(n for n, d, e in bench_wave64.CONFIGS if d == driver and e == emulate)
|
|
calls[name] = calls.get(name, 0) + 1
|
|
if fail.get(name) == calls[name]:
|
|
return None, "exit 1: device lost", None
|
|
return (1.0, 0.9), "same", "stub GPU"
|
|
|
|
out = io.StringIO()
|
|
with patch.object(bench_wave64, "build", lambda work, name, emulate, llvm_mc: f"{name}-{emulate}.spv"), \
|
|
patch.object(bench_wave64, "segments", lambda spv: None), \
|
|
patch.object(bench_wave64, "run", run), \
|
|
patch.object(sys, "argv", ["bench_wave64.py", "--procs", "2"]), \
|
|
contextlib.redirect_stdout(out):
|
|
code = bench_wave64.main()
|
|
return code, out.getvalue()
|
|
|
|
|
|
class PartialFailure(unittest.TestCase):
|
|
def test_every_process_ran(self):
|
|
code, out = bench({})
|
|
self.assertEqual(code, 0, out)
|
|
self.assertIn("emulated output equals the reference", out)
|
|
|
|
def test_emulated_config_fails_on_its_second_process(self):
|
|
code, out = bench({"NVIDIA --wave64-emulate": 2})
|
|
self.assertEqual(code, 1, out)
|
|
self.assertIn("NVIDIA --wave64-emulate: failed or unsupported", out)
|
|
|
|
def test_reference_fails_on_its_second_process(self):
|
|
code, out = bench({"AMD native": 2})
|
|
self.assertEqual(code, 1, out)
|
|
self.assertIn("no reference output from AMD native", out)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|