mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:48:38 +00:00
On Windows 11, Smart App Control blocks freshly built unsigned programs it
has no reputation for (WinError 4551, "An Application Control policy has
blocked this file"), and which ones it blocks changes with each rebuild.
run_gpu_tests.py then stopped the whole run with an OSError traceback, and
check.py did the same from mesh_w64x_test.
- check.start_failure() turns the OSError into one result line naming the
program and, for the Windows refusals (4551 Application Control, 1260
software restriction policy, 225 Defender), who refused it and how to
allow it.
- check.run(), mesh_w64x_test(), run_gpu_tests.run_cmd() and the
ps_texture_sample launch report it as a FAIL of that test and go on with
the rest. It is a failure, not a SKIP: a blocked run must not look green.
pixel_test() passes the reason on instead of "vk_harness failed".
- A missing program still stops check.py with the build instructions.
tests/test_gpu_blocked_program.py fakes the error, so it runs on any OS.
AI-assisted (Claude Code). Tested on Windows 11 Home, NVIDIA GeForce RTX
4060 Ti (driver 32.0.16.2124), on main 36ace71:
- the new tests: 7/7 on Windows and on Linux (WSL Ubuntu 26.04); 5 of
them fail without the fix
- end to end, with test programs Windows really refuses (WinError 216):
run_gpu_tests.py and check.py print one FAIL line per test and exit 1,
no traceback
- run_gpu_tests.py: every PASS/SKIP identical to main, natively (29/49,
20 skipped) and with LEONIDA_W64_EMULATE=1 (47/49, 2 skipped); ctest
12/12; tests/test_*.py all pass; tests/semantic 388 OK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
4.0 KiB
Python
84 lines
4.0 KiB
Python
"""A test program Windows refuses to start (Smart App Control blocks fresh unsigned builds: WinError 4551) is one
|
|
failed test with the reason, not a traceback that ends the run. The error is faked, so this runs on any OS."""
|
|
from pathlib import Path
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "runtime" / "test" / "shaders"))
|
|
sys.path.insert(0, str(ROOT / "scripts"))
|
|
import check
|
|
import run_gpu_tests
|
|
|
|
|
|
def blocked(winerror=4551):
|
|
"""The OSError Python raises on Windows when Application Control refuses to start a program."""
|
|
e = PermissionError(13, "An Application Control policy has blocked this file")
|
|
e.winerror = winerror
|
|
return e
|
|
|
|
|
|
class CheckPy(unittest.TestCase):
|
|
def test_blocked_program_is_a_failed_test(self):
|
|
with patch.object(check.subprocess, "run", side_effect=blocked()):
|
|
code, out = check.run("/build/vk_compute_test.exe", "cs_lds.spv", "4", "mirror64")
|
|
self.assertNotEqual(code, 0)
|
|
self.assertNotEqual(code, check.UNSUPPORTED) # a blocked program is not a device limit: no SKIP
|
|
self.assertIn("could not start vk_compute_test.exe", out)
|
|
self.assertIn("Application Control", out)
|
|
|
|
def test_blocked_mesh_harness_is_a_failed_test(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
for name in ("ms_w64x_ballot", "fs_passthru"):
|
|
(Path(tmp) / f"{name}.spv").touch()
|
|
with patch.object(check.subprocess, "run", side_effect=blocked()):
|
|
problem = check.mesh_w64x_test(tmp, tmp, "ms_w64x_ballot")
|
|
self.assertNotIsInstance(problem, check.Skip)
|
|
self.assertIn("could not start vk_harness", problem)
|
|
self.assertIn("Application Control", problem)
|
|
|
|
def test_blocked_pixel_harness_gives_the_reason(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
(Path(tmp) / "ps_ops.spv").touch()
|
|
with patch.object(check.subprocess, "run", side_effect=blocked()):
|
|
problem = check.pixel_test(tmp, tmp, "ps_ops")
|
|
self.assertNotIsInstance(problem, check.Skip)
|
|
self.assertIn("could not start vk_harness", problem)
|
|
self.assertIn("Application Control", problem)
|
|
|
|
def test_other_start_errors_quote_the_error(self):
|
|
with patch.object(check.subprocess, "run", side_effect=OSError(8, "Exec format error")):
|
|
code, out = check.run("/build/vk_harness", "a.spv")
|
|
self.assertNotEqual(code, 0)
|
|
self.assertIn("could not start vk_harness: [Errno 8] Exec format error", out)
|
|
self.assertNotIn("Application Control", out)
|
|
|
|
def test_missing_programs_still_say_how_to_build_them(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
with patch.object(check.subprocess, "run", side_effect=FileNotFoundError(2, "not found")):
|
|
with self.assertRaises(SystemExit) as stop:
|
|
check.run(str(Path(tmp) / "vk_compute_test"), "cs_lds.spv")
|
|
self.assertIn("Test programs not found", str(stop.exception))
|
|
|
|
def test_each_windows_refusal_names_who_refused(self):
|
|
for code, who in ((4551, "Application Control"), (1260, "software restriction policy"),
|
|
(225, "Microsoft Defender")):
|
|
self.assertIn(who, check.start_failure("vk_store_test.exe", blocked(code)))
|
|
|
|
|
|
class RunGpuTestsPy(unittest.TestCase):
|
|
def test_blocked_program_is_a_failed_test(self):
|
|
with patch.object(run_gpu_tests.subprocess, "run", side_effect=blocked()):
|
|
code, msg = run_gpu_tests.run_cmd(["C:/build/vk_compute_test.exe", "cs_bvh.spv", "1", "bvh"])
|
|
self.assertNotEqual(code, 0)
|
|
self.assertNotEqual(code, run_gpu_tests.UNSUPPORTED)
|
|
self.assertIn("could not start vk_compute_test.exe", msg)
|
|
self.assertIn("Application Control", msg)
|
|
self.assertEqual(len(msg.splitlines()), 1) # one result line in the summary table
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|