Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions eng/graphics/tests/test_verify_sdk_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import importlib.util
from pathlib import Path
import unittest


ROOT = Path(__file__).resolve().parents[3]
SPEC = importlib.util.spec_from_file_location(
"verify_sdk", ROOT / "eng/graphics/verify-sdk.py")
VERIFY_SDK = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(VERIFY_SDK)


class DawnSymbolPolicyTests(unittest.TestCase):
def test_current_policy_is_accepted_for_every_rid(self):
for rid in ("osx-arm64", "linux-x64", "win-x64"):
self.assertTrue(
VERIFY_SDK.symbol_policy_matches("current", "current", rid))

def test_qualified_legacy_policy_is_macos_only(self):
legacy = next(iter(VERIFY_SDK.LEGACY_OSX_DAWN_SYMBOL_POLICIES))
self.assertTrue(
VERIFY_SDK.symbol_policy_matches(legacy, "current", "osx-arm64"))
self.assertFalse(
VERIFY_SDK.symbol_policy_matches(legacy, "current", "linux-x64"))
self.assertFalse(
VERIFY_SDK.symbol_policy_matches(legacy, "current", "win-x64"))

def test_unknown_policy_fails_closed(self):
for rid in ("osx-arm64", "linux-x64", "win-x64"):
self.assertFalse(
VERIFY_SDK.symbol_policy_matches("unknown", "current", rid))


if __name__ == "__main__":
unittest.main()
18 changes: 17 additions & 1 deletion eng/graphics/verify-sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

LOCK_PATH = Path(__file__).with_name("dependencies.lock.json")
ROOT = Path(__file__).resolve().parents[2]
LEGACY_OSX_DAWN_SYMBOL_POLICIES = frozenset({
# Qualified before the Linux/Windows native-device bridge was added. The
# Apple branch still exports the same bounded wgpu* surface; the bridge is
# deliberately not compiled for macOS.
"375d05a693311a8dd981d265b9291dbd5ff0ac482442422771ab4faca573938c",
})


def sha(path):
Expand All @@ -18,6 +24,13 @@ def sha(path):
return digest.hexdigest()


def symbol_policy_matches(installed_digest, current_digest, rid):
return installed_digest == current_digest or (
rid.startswith("osx-")
and installed_digest in LEGACY_OSX_DAWN_SYMBOL_POLICIES
)


def verify(sdk, component, rid):
lock = json.loads(LOCK_PATH.read_text())
manifest_path = sdk / "webscene-graphics-package.json"
Expand Down Expand Up @@ -74,7 +87,10 @@ def verify(sdk, component, rid):
or files.get("licenses/windows-sdk/LICENSE.rtf") != pin["licenseSha256"]
or files.get("build-info/windows-runtime.json") != sha(LOCK_PATH.with_name("windows-runtime.json"))):
raise ValueError("dawn: pinned Windows shader compiler or license mismatch")
if sha(sdk / "build-info/DawnSymbolBoundary.cmake") != sha(LOCK_PATH.with_name("DawnSymbolBoundary.cmake")):
if not symbol_policy_matches(
sha(sdk / "build-info/DawnSymbolBoundary.cmake"),
sha(LOCK_PATH.with_name("DawnSymbolBoundary.cmake")),
rid):
raise ValueError("dawn: symbol isolation policy mismatch; rebuild the SDK")
if rid.startswith(("linux-", "win-")):
bridge_files = {
Expand Down
Loading