test_mse_r10_td_resources.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. """Round-10: TD resource parser and production-source hash compare."""
  2. from __future__ import annotations
  3. from pathlib import Path
  4. from tools import package_provenance as pkg_prov
  5. ROOT = Path(__file__).resolve().parents[2]
  6. def test_parse_td_resources_keeps_explicit_mslice_1089():
  7. compact = {
  8. "lut": 3901,
  9. "mslice": 1089,
  10. "dsp": 1,
  11. "resources": {
  12. "utilization": {
  13. "lut": {"used": 4320},
  14. "dsp": {"used": 1},
  15. },
  16. "packing": {"mslice": 1089, "lslice": 1089, "total_slices": 2178},
  17. },
  18. }
  19. parsed = pkg_prov.parse_td_resource_fields(compact)
  20. assert parsed["lut"] == 4320
  21. assert parsed["mslice"] == 1089
  22. assert parsed["dsp"] == 1
  23. def test_parse_td_resources_never_falls_back_lut_to_mslice():
  24. compact = {
  25. "resources": {
  26. "utilization": {
  27. "lut": {"used": 4320},
  28. "le": {"used": 4320},
  29. "dsp": {"used": 1},
  30. }
  31. }
  32. }
  33. parsed = pkg_prov.parse_td_resource_fields(compact)
  34. assert parsed["lut"] == 4320
  35. assert parsed["mslice"] is None
  36. assert parsed["dsp"] == 1
  37. def test_canonical_identity_mslice_is_1089_not_4320():
  38. td = pkg_prov.load_canonical_td_a1_fields(ROOT)
  39. ident = pkg_prov.build_shared_release_identity(
  40. delivery_commit="d91a7b46a37371d9a03ae47c5245da2eb4561772",
  41. package_stage="intermediate-review",
  42. matrix_verification_tip="d126c3df0ceef3de4d559b60253fb5336da11922",
  43. software_verification_run_id="mse-r9-20260812T163229Z",
  44. config_fingerprint="x",
  45. reference_set_fingerprint="y",
  46. repo_root=ROOT,
  47. claim_bound_bitstream=True,
  48. )
  49. assert td["mslice"] == 1089
  50. assert ident["mslice"] == 1089
  51. assert ident["lut"] == 4320
  52. def test_artifact_to_delivery_hash_compare_not_commit_equality():
  53. artifact = "ff44128a540b7ffd9d82314093b242ac3aee92d7"
  54. delivery = "d91a7b46a37371d9a03ae47c5245da2eb4561772"
  55. assert artifact != delivery
  56. cmp_ = pkg_prov.compare_production_source_commits(
  57. from_commit=artifact,
  58. to_commit=delivery,
  59. repo_root=ROOT,
  60. )
  61. assert cmp_["unchanged"] is True
  62. assert cmp_["production_changed_paths"] == []
  63. rel = pkg_prov.build_source_closure_relations(
  64. old_baseline_commit=pkg_prov.BASE_DEV_COMMIT_DEFAULT,
  65. artifact_commit=artifact,
  66. delivery_commit=delivery,
  67. old_to_artifact_unchanged=False,
  68. artifact_to_delivery_unchanged=True,
  69. old_to_artifact_changed_paths=["projects/prod2u-door-temp/project.json"],
  70. artifact_to_delivery_changed_paths=[],
  71. comparison_mode="snapshot_hash",
  72. )
  73. check = pkg_prov.validate_source_closure_relations(rel)
  74. assert check["status"] == "pass", check
  75. def test_snapshot_hash_false_empty_paths_fails():
  76. rel = pkg_prov.build_source_closure_relations(
  77. old_baseline_commit=pkg_prov.BASE_DEV_COMMIT_DEFAULT,
  78. artifact_commit="aa",
  79. delivery_commit="bb",
  80. old_to_artifact_unchanged=False,
  81. artifact_to_delivery_unchanged=False,
  82. old_to_artifact_changed_paths=[],
  83. artifact_to_delivery_changed_paths=[],
  84. comparison_mode="snapshot_hash",
  85. )
  86. check = pkg_prov.validate_source_closure_relations(rel)
  87. assert check["status"] == "fail"
  88. assert any("empty_paths" in f for f in check["failures"])