53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Self-contained checks for Release selection and effective VPSS graph."""
|
|
|
|
import json
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
from audit_cv181x_media_ai import audit
|
|
|
|
|
|
def put(path: Path, value):
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(json.dumps(value), encoding="utf-8")
|
|
|
|
|
|
def main():
|
|
with tempfile.TemporaryDirectory() as temporary:
|
|
root = Path(temporary)
|
|
media = root / "EmxMedia-20260917-1" / "cv181xArmMuslDefault"
|
|
ai = root / "EmxAiPlugin-20260921-1" / "cv181xArmMusl"
|
|
psp = root / "PSP"
|
|
identity = {"ChipSerial": "cv181x", "ChipSdkVersion": "4.1.6_arm_musl",
|
|
"ChipManufactory": "cvitek", "Cross": "arm-none-linux-musleabihf",
|
|
"EmxSdkVersion": "EmxSdk-20260917-1"}
|
|
put(media / "configs.json", identity)
|
|
put(ai / "profile.json", identity)
|
|
put(ai / "AiPlugin.json", {"profile": ai.name, "version": "20260921-1"})
|
|
system = [{"vb": [{"cnt": 2}], "vpss": {"group": [
|
|
{"vpssGrp": 0, "chn": [{"u32Width": 640}], "attachPool": [{"chn": 0, "pool": 0}], "bind": []}
|
|
]}}]
|
|
put(media / "configs/system.json", system)
|
|
put(media / "configs/venc.json", [{"attr": {"VpssGrp": 0, "VpssChn": 0}}])
|
|
put(ai / "configs/config.json", {"PersonDetection": True})
|
|
put(ai / "configs/PersonDetection.json", [{"vpssGrp": 0, "vpssChn": 0}])
|
|
result = audit(media, ai)
|
|
assert result["passed_static_cross_checks"] is True, result["errors"]
|
|
assert result["field_counts"]["media"] > 0
|
|
put(psp / "psp.json", {"EmxMediaVersion": media.parent.name, "EmxMediaProfile": media.name,
|
|
"EmxAiPluginVersion": ai.parent.name, "EmxAiPluginProfile": ai.name})
|
|
put(psp / "configs/media/scene/default/system.json", system)
|
|
put(psp / "configs/media/scene/default/venc.json", [{"attr": {"VpssGrp": 4, "VpssChn": 0}}])
|
|
changed = audit(media, ai, psp=psp)
|
|
assert changed["passed_static_cross_checks"] is False
|
|
assert any("VPSS 4/0" in error for error in changed["errors"])
|
|
assert any(row.get("field") == "[0].attr.VpssGrp" for row in changed["candidate_differences"])
|
|
put(ai / "profile.json", {**identity, "EmxSdkVersion": "EmxSdk-20260110-1"})
|
|
mismatch = audit(media, ai)
|
|
assert any("EmxSdkVersion" in error for error in mismatch["errors"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|