diff --git a/project_tuxbox/verify.py b/project_tuxbox/verify.py index 76e00913..883ae699 100644 --- a/project_tuxbox/verify.py +++ b/project_tuxbox/verify.py @@ -460,9 +460,11 @@ def expect_root_translations(output): return "the provider substituted a stand-in for the program its root can bind" return None - names = ("TUXBOX_LOG", "WINEDEBUG", "TUXBOX_SHADER_SESSION") + # This gate deliberately checks one refused program's stand-in. Do not + # inherit the caller's policy for the real game or another verification gate. + names = ("TUXBOX_LOG", "WINEDEBUG", "TUXBOX_SHADER_SESSION", "TUXBOX_NULL_PIPELINES") saved = {name: host.env.get(name) for name in names} - host.env.update(TUXBOX_LOG="1", WINEDEBUG="-all,+debugstr") + host.env.update(TUXBOX_LOG="1", WINEDEBUG="-all,+debugstr", TUXBOX_NULL_PIPELINES="1") host.env.pop("TUXBOX_SHADER_SESSION", None) try: forget(rootless) diff --git a/tests/test_lanes_compute_root.py b/tests/test_lanes_compute_root.py index d1d72ef8..96a87999 100644 --- a/tests/test_lanes_compute_root.py +++ b/tests/test_lanes_compute_root.py @@ -68,7 +68,7 @@ class ComputeRootGateTests(unittest.TestCase): STAND_IN = "substituted null compute pipeline for an untranslated shader (1 so far)\n" REFUSAL = "unmapped descriptor at s5 + 0xa0" - def run_gate(self, output, compiled, refused): + def run_gate(self, output, compiled, refused, null_policy=None): rootless = [hashlib.sha256(shader_fixture.root_shader(offset)).hexdigest() for offset in (0x40, 0xA0)] with TemporaryDirectory() as prefix: sources = Path(prefix) / SOURCE_CACHE @@ -80,6 +80,8 @@ def run_gate(self, output, compiled, refused): for path in (*stale, kept): path.write_bytes(b"") env = {"WINEPREFIX": prefix, "TUXBOX_SHADER_SESSION": "1", "TUXBOX_LOG": "stderr"} + if null_policy is not None: + env["TUXBOX_NULL_PIPELINES"] = null_policy seen = {} @contextmanager @@ -118,6 +120,14 @@ def test_root_translations_pass_and_clean_their_entries(self): self.assertEqual(seen["env_after"]["TUXBOX_SHADER_SESSION"], "1") self.assertEqual(seen["env_after"]["TUXBOX_LOG"], "stderr") + def test_null_policy_is_explicit_and_restored(self): + for policy in (None, "0", "1"): + with self.subTest(policy=policy): + seen, _ = self.run_gate(self.STAND_IN, ["a"*64], [("b"*64, self.REFUSAL)], policy) + self.assertEqual(seen["env"]["TUXBOX_NULL_PIPELINES"], "1") + self.assertEqual(seen["env_after"].get("TUXBOX_NULL_PIPELINES"), policy) + self.assertIsNone(seen["problem"]) + def test_rootless_fallback_fails(self): rootless = self.run_gate(self.STAND_IN, [], [])[1] refusal = [("b" * 64, self.REFUSAL)]