Merge pull request #1841 from delysidemanYT1/gpu-disasm-scratch-error

GPU-DISASM-SCRATCH-ERROR: Report GPU disassembly staging failures before translation
This commit is contained in:
MoonEyes
2026-11-29 00:50:07 +01:00
committed by GitHub
2 changed files with 39 additions and 3 deletions

View File

@ -949,9 +949,18 @@ def run_suite(a, work: str) -> int:
Path(spirv_dir, f"{name}.spv").unlink(missing_ok=True)
# 2. Translate this run's inputs only. The translator looks for metadata one level above the input directory.
with tempfile.TemporaryDirectory(prefix="disasm-", dir=work) as selected_disasm:
for path in disasm_files:
shutil.copyfile(path, os.path.join(selected_disasm, os.path.basename(path)))
try:
staging = tempfile.TemporaryDirectory(prefix="disasm-", dir=work)
except OSError as exc:
print(f"error: cannot create a disassembly staging directory in {work}: {exc}", file=sys.stderr)
return 2
with staging as selected_disasm:
try:
for path in disasm_files:
shutil.copyfile(path, os.path.join(selected_disasm, os.path.basename(path)))
except OSError as exc:
print(f"error: cannot stage disassembly for translation: {exc}", file=sys.stderr)
return 2
cmd = [sys.executable, "-I", TRANSLATOR, selected_disasm, "--out", spirv_dir]
if assembler == "python":
cmd += ["--assembler", "python"]

View File

@ -50,6 +50,33 @@ class DrawShaders(unittest.TestCase):
class FilterSelection(unittest.TestCase):
def test_cannot_create_disassembly_staging_directory(self):
err = io.StringIO()
with tempfile.TemporaryDirectory() as tmp, \
patch("sys.stderr", err), \
patch.object(run_gpu_tests, "assemble_to_s"), \
patch.object(run_gpu_tests.tempfile, "TemporaryDirectory", side_effect=PermissionError("access denied")), \
patch.object(run_gpu_tests, "run_cmd") as run:
args = SimpleNamespace(filter="cs_lds", llvm_mc="unused")
self.assertEqual(run_gpu_tests.run_suite(args, tmp), 2)
self.assertIn("cannot create a disassembly staging directory", err.getvalue())
self.assertIn("access denied", err.getvalue())
run.assert_not_called()
def test_cannot_copy_disassembly_into_staging_directory(self):
err = io.StringIO()
with tempfile.TemporaryDirectory() as tmp, \
patch("sys.stderr", err), \
patch.object(run_gpu_tests, "assemble_to_s"), \
patch.object(run_gpu_tests.shutil, "copyfile", side_effect=PermissionError("access denied")), \
patch.object(run_gpu_tests, "run_cmd") as run:
args = SimpleNamespace(filter="cs_lds", llvm_mc="unused")
self.assertEqual(run_gpu_tests.run_suite(args, tmp), 2)
self.assertEqual(list(Path(tmp).glob("disasm-*")), [])
self.assertIn("cannot stage disassembly for translation", err.getvalue())
self.assertIn("access denied", err.getvalue())
run.assert_not_called()
def test_reused_work_translates_only_selected_shaders_and_dependencies(self):
passes = []