This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Validate Phase-1.0AR bindings and absence of live channel capability."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def digest(path: Path) -> tuple[int, str]:
|
||||
data = path.read_bytes()
|
||||
return len(data), hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
root = parser.parse_args().root
|
||||
data = json.loads((root / "manifests/retroarch/phase-1.0ar-result-channel-model.json").read_text(encoding="utf-8"))
|
||||
bindings = data["source_bindings"]
|
||||
assert hashlib.sha256((root / "manifests/retroarch/phase-1.0aq-worker-result-record.json").read_bytes()).hexdigest() == bindings["phase10aq_manifest_sha256"]
|
||||
for prefix, relative in (("model", "tools/phase10ar_result_channel_model.py"),
|
||||
("tests", "tests/test_phase10ar_result_channel_model.py")):
|
||||
size, sha256 = digest(root / relative)
|
||||
assert size == bindings[f"{prefix}_size"]
|
||||
assert sha256 == bindings[f"{prefix}_sha256"]
|
||||
tree = ast.parse((root / "tools/phase10ar_result_channel_model.py").read_text(encoding="utf-8"))
|
||||
imports = {alias.name.split(".")[0] for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Import) for alias in node.names}
|
||||
imports.update(node.module.split(".")[0] for node in ast.walk(tree)
|
||||
if isinstance(node, ast.ImportFrom) and node.module)
|
||||
assert not imports.intersection({"os", "sys", "pathlib", "subprocess", "socket", "selectors", "select", "ctypes", "time"})
|
||||
channel = data["channel"]
|
||||
assert channel["eof_is_success"] is False
|
||||
assert channel["record_completion_is_success_boundary"] is True
|
||||
assert channel["live_pipe_present"] is False
|
||||
assert not any(data["authorizations"].values())
|
||||
assert data["decision"]["live_channel_implementation_allowed"] is False
|
||||
print("Phase-1.0AR result channel validation passed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user