Files
Chimera GFX release export a6037502d7
phase0-ci / build-and-audit (push) Successful in 2m14s
Publish Chimera GFX source
2026-09-03 03:27:14 +02:00

61 lines
2.3 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Unit test for strict PS5 ELF import parsing."""
from __future__ import annotations
import argparse
import importlib.util
from pathlib import Path
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--root", type=Path, required=True)
args = parser.parse_args()
tool_path = args.root.resolve() / "tools/audit_ps5_artifacts.py"
specification = importlib.util.spec_from_file_location("artifact_audit", tool_path)
if specification is None or specification.loader is None:
raise RuntimeError("could not load artifact-audit module")
module = importlib.util.module_from_spec(specification)
specification.loader.exec_module(module)
fixture = """
U fprintf
U sceKernelCreateEqueue
U sceVideoOutOpen
0000000000001234 T sceVideoOutClose
"""
imports = module.extract_sce_imports(fixture)
if imports != {"sceKernelCreateEqueue", "sceVideoOutOpen"}:
raise RuntimeError(f"unexpected parsed imports: {imports}")
if len(module.EXPECTED_PHASE1_SCE_IMPORTS) != 15:
raise RuntimeError("reviewed Phase-1 import inventory changed")
if any(name.startswith("sceGnm") for name in module.EXPECTED_PHASE1_SCE_IMPORTS):
raise RuntimeError("reviewed Phase-1 import inventory contains GNM")
all_imports = module.extract_undefined_imports(fixture)
if all_imports != {"fprintf", "sceKernelCreateEqueue", "sceVideoOutOpen"}:
raise RuntimeError(f"unexpected full import inventory: {all_imports}")
if module.EXPECTED_PROBE_UNDEFINED_IMPORTS != {
"__stderrp",
"__stdoutp",
"fprintf",
"fwrite",
"snprintf",
"strcmp",
}:
raise RuntimeError("reviewed probe import inventory changed")
dynamic_fixture = """
0x0000000000000001 (NEEDED) Shared library: [libkernel_web.sprx]
0x0000000000000001 (NEEDED) Shared library: [libSceLibcInternal.sprx]
0x0000000000000001 (NEEDED) Shared library: [libSceNet.sprx]
"""
if module.extract_needed(dynamic_fixture) != module.EXPECTED_PROBE_NEEDED:
raise RuntimeError("reviewed probe DT_NEEDED inventory changed")
print("PS5 artifact-audit parser passed")
return 0
if __name__ == "__main__":
raise SystemExit(main())