| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- """Round-10: TD resource parser and production-source hash compare."""
- from __future__ import annotations
- from pathlib import Path
- from tools import package_provenance as pkg_prov
- ROOT = Path(__file__).resolve().parents[2]
- def test_parse_td_resources_keeps_explicit_mslice_1089():
- compact = {
- "lut": 3901,
- "mslice": 1089,
- "dsp": 1,
- "resources": {
- "utilization": {
- "lut": {"used": 4320},
- "dsp": {"used": 1},
- },
- "packing": {"mslice": 1089, "lslice": 1089, "total_slices": 2178},
- },
- }
- parsed = pkg_prov.parse_td_resource_fields(compact)
- assert parsed["lut"] == 4320
- assert parsed["mslice"] == 1089
- assert parsed["dsp"] == 1
- def test_parse_td_resources_never_falls_back_lut_to_mslice():
- compact = {
- "resources": {
- "utilization": {
- "lut": {"used": 4320},
- "le": {"used": 4320},
- "dsp": {"used": 1},
- }
- }
- }
- parsed = pkg_prov.parse_td_resource_fields(compact)
- assert parsed["lut"] == 4320
- assert parsed["mslice"] is None
- assert parsed["dsp"] == 1
- def test_canonical_identity_mslice_is_1089_not_4320():
- td = pkg_prov.load_canonical_td_a1_fields(ROOT)
- ident = pkg_prov.build_shared_release_identity(
- delivery_commit="d91a7b46a37371d9a03ae47c5245da2eb4561772",
- package_stage="intermediate-review",
- matrix_verification_tip="d126c3df0ceef3de4d559b60253fb5336da11922",
- software_verification_run_id="mse-r9-20260812T163229Z",
- config_fingerprint="x",
- reference_set_fingerprint="y",
- repo_root=ROOT,
- claim_bound_bitstream=True,
- )
- assert td["mslice"] == 1089
- assert ident["mslice"] == 1089
- assert ident["lut"] == 4320
- def test_artifact_to_delivery_hash_compare_not_commit_equality():
- artifact = "ff44128a540b7ffd9d82314093b242ac3aee92d7"
- delivery = "d91a7b46a37371d9a03ae47c5245da2eb4561772"
- assert artifact != delivery
- cmp_ = pkg_prov.compare_production_source_commits(
- from_commit=artifact,
- to_commit=delivery,
- repo_root=ROOT,
- )
- assert cmp_["unchanged"] is True
- assert cmp_["production_changed_paths"] == []
- rel = pkg_prov.build_source_closure_relations(
- old_baseline_commit=pkg_prov.BASE_DEV_COMMIT_DEFAULT,
- artifact_commit=artifact,
- delivery_commit=delivery,
- old_to_artifact_unchanged=False,
- artifact_to_delivery_unchanged=True,
- old_to_artifact_changed_paths=["projects/prod2u-door-temp/project.json"],
- artifact_to_delivery_changed_paths=[],
- comparison_mode="snapshot_hash",
- )
- check = pkg_prov.validate_source_closure_relations(rel)
- assert check["status"] == "pass", check
- def test_snapshot_hash_false_empty_paths_fails():
- rel = pkg_prov.build_source_closure_relations(
- old_baseline_commit=pkg_prov.BASE_DEV_COMMIT_DEFAULT,
- artifact_commit="aa",
- delivery_commit="bb",
- old_to_artifact_unchanged=False,
- artifact_to_delivery_unchanged=False,
- old_to_artifact_changed_paths=[],
- artifact_to_delivery_changed_paths=[],
- comparison_mode="snapshot_hash",
- )
- check = pkg_prov.validate_source_closure_relations(rel)
- assert check["status"] == "fail"
- assert any("empty_paths" in f for f in check["failures"])
|