| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- from __future__ import annotations
- import copy
- import importlib.util
- import json
- from pathlib import Path
- import pytest
- RUNNER_PATH = Path(__file__).with_name("run_hthd_6400_pty_rtl.py")
- SPEC = importlib.util.spec_from_file_location("hth_6400_rtl_runner", RUNNER_PATH)
- assert SPEC is not None and SPEC.loader is not None
- RUNNER = importlib.util.module_from_spec(SPEC)
- SPEC.loader.exec_module(RUNNER)
- BUILD_PATH = RUNNER.HOST / "tools" / "build_amd64_release.py"
- BUILD_SPEC = importlib.util.spec_from_file_location("hth_amd64_release_builder", BUILD_PATH)
- assert BUILD_SPEC is not None and BUILD_SPEC.loader is not None
- BUILD = importlib.util.module_from_spec(BUILD_SPEC)
- BUILD_SPEC.loader.exec_module(BUILD)
- def imported() -> dict[str, object]:
- return json.loads(RUNNER.IMPORT_META.read_text(encoding="utf-8"))
- def test_v11_commit_binds_functional_and_package_sources() -> None:
- provenance = imported()
- assert provenance["source_commit"] == "4a140b10e4227bf426d9cc5a3ae8617330f728a7"
- assert provenance["package_commit"] == "4a140b10e4227bf426d9cc5a3ae8617330f728a7"
- assert provenance["contract_sha256"] == (
- "9b2df5161fb37e4b84af8337c5e99a78e27b6058934a245068afd2d533468def"
- )
- assert provenance["source_commit"] == provenance["package_commit"]
- sources = RUNNER._bound_sources_from_import(provenance)
- assert any(path.name == "prod2u_6400_v1_top.v" for path in sources)
- assert any(path.name == "prod2u_6400_rs232_only_top.v" for path in sources)
- def test_exact_source_hash_gate_rejects_drift() -> None:
- provenance = copy.deepcopy(imported())
- file_hashes = provenance["source_input_file_sha256"]
- assert isinstance(file_hashes, dict)
- file_hashes["src/top/prod2u_6400_v1_top.v"] = "0" * 64
- with pytest.raises(RuntimeError, match="CPLD source input .* SHA"):
- RUNNER._bound_sources_from_import(provenance)
- def test_release_metadata_binds_current_v11_rebuild_commit() -> None:
- value = BUILD.cpld_provenance(RUNNER.HOST)
- assert value["functional_source_commit"] == (
- "4a140b10e4227bf426d9cc5a3ae8617330f728a7"
- )
- assert value["package_commit"] == "4a140b10e4227bf426d9cc5a3ae8617330f728a7"
- assert value["td_bitstream_source_commit"] == value["functional_source_commit"]
- assert value["td_bitstream_rebuilt_from_package_commit"] is True
- assert value["firmware_artifact_included"] is False
|