|
@@ -0,0 +1,49 @@
|
|
|
|
|
+#!/usr/bin/env python3
|
|
|
|
|
+"""Unit tests for package-time verification→delivery closure and topic naming."""
|
|
|
|
|
+
|
|
|
|
|
+from __future__ import annotations
|
|
|
|
|
+
|
|
|
|
|
+import os
|
|
|
|
|
+import unittest
|
|
|
|
|
+from pathlib import Path
|
|
|
|
|
+
|
|
|
|
|
+ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
+import sys
|
|
|
|
|
+
|
|
|
|
|
+sys.path.insert(0, str(ROOT / "tools"))
|
|
|
|
|
+
|
|
|
|
|
+import package_provenance as pkg_prov # noqa: E402
|
|
|
|
|
+import verification_to_delivery_closure as v2d # noqa: E402
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class TopicNamingTests(unittest.TestCase):
|
|
|
|
|
+ def test_default_topic_is_mse_a1(self) -> None:
|
|
|
|
|
+ os.environ.pop("PRODU2_RELEASE_TASK_SLUG", None)
|
|
|
|
|
+ os.environ.pop("PRODU2_PACKAGE_TOPIC", None)
|
|
|
|
|
+ self.assertEqual(pkg_prov.release_task_slug(), "mse-a1")
|
|
|
|
|
+ name = pkg_prov.release_sibling_filename("review-compact", "abcdef12deadbeef")
|
|
|
|
|
+ self.assertIn("mse-a1", name)
|
|
|
|
|
+ self.assertNotIn("door-percent", name)
|
|
|
|
|
+
|
|
|
|
|
+ def test_deprecated_alias_keeps_door_percent(self) -> None:
|
|
|
|
|
+ alias = pkg_prov.deprecated_door_percent_alias(
|
|
|
|
|
+ "review-selftest", "abcdef12deadbeef"
|
|
|
|
|
+ )
|
|
|
|
|
+ self.assertIn("door-percent", alias)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class ClosureClassifyTests(unittest.TestCase):
|
|
|
|
|
+ def test_production_rtl_forbidden(self) -> None:
|
|
|
|
|
+ self.assertEqual(v2d._classify("src/modules/door_shared_dda_scheduler.v"), "forbidden")
|
|
|
|
|
+ self.assertEqual(v2d._classify("constraints/prod2u_p4_normal_v3.adc"), "forbidden")
|
|
|
|
|
+ self.assertEqual(v2d._classify("td/syn/prod2u_p4_normal_v3.tcl"), "forbidden")
|
|
|
|
|
+
|
|
|
|
|
+ def test_receipts_and_docs_allowed(self) -> None:
|
|
|
|
|
+ self.assertEqual(v2d._classify("receipts/mse-r8/x.json"), "allowed")
|
|
|
|
|
+ self.assertEqual(v2d._classify("evidence/formal/formal-receipt.json"), "allowed")
|
|
|
|
|
+ self.assertEqual(v2d._classify("README.zh-CN.md"), "allowed")
|
|
|
|
|
+ self.assertEqual(v2d._classify("tools/package_provenance.py"), "allowed")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+if __name__ == "__main__":
|
|
|
|
|
+ unittest.main()
|