| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- from __future__ import annotations
- import json
- from pathlib import Path
- ROOT = Path(__file__).resolve().parents[2]
- BOARD_DATA = ROOT / "tools" / "board-viewer" / "generated" / "board-data.json"
- def load_board_data() -> dict[str, object]:
- return json.loads(BOARD_DATA.read_text(encoding="utf-8"))
- def by_reference(payload: dict[str, object]) -> dict[str, dict[str, object]]:
- return {item["reference"]: item for item in payload["touchpoints"]}
- def pins(touchpoint: dict[str, object]) -> dict[str, dict[str, object]]:
- return {item["number"]: item for item in touchpoint["pins"] if item["number"]}
- def test_every_connector_and_testpoint_has_reviewed_functional_copy() -> None:
- payload = load_board_data()
- targets = [
- item
- for item in payload["touchpoints"]
- if item["category"] in {"CON", "TP"}
- ]
- # V1.2 FCB_FPGA+MCU: 88 CON + 8 TP (TP1–TP7, TP31). V1.1 had 91 with TP9+ / CON58/65.
- assert len(targets) == 96
- assert all("用途未注释" not in item["summary"] for item in targets)
- for touchpoint in targets:
- reviewed_pins = [
- pin
- for pin in touchpoint["pins"]
- if touchpoint["category"] == "TP" or pin["pad_role"] == "contact"
- ]
- assert reviewed_pins, touchpoint["reference"]
- assert all(not pin["summary"].startswith("板内网络 ") for pin in reviewed_pins), touchpoint["reference"]
- def test_power_bmc_rs485_and_fan_connector_semantics_are_anchored() -> None:
- refs = by_reference(load_board_data())
- con2 = pins(refs["CON2"])
- assert "+12V 主电源输入 1" in refs["CON2"]["summary"]
- assert all(con2[number]["function_category"] == "ground" for number in ("1", "2", "3", "4"))
- assert all("+12V" in con2[number]["summary"] for number in ("5", "6", "7", "8"))
- assert con2["5"]["programming"]["evidence_tier"] == "cross_verified"
- assert "板端电源输入" in con2["5"]["programming"]["network_explanation"]
- assert "CON2.5 +12V_VIN" in con2["5"]["programming"]["network_explanation"]
- con31 = pins(refs["CON31"])
- assert "+12V_FAN7" in refs["CON31"]["summary"]
- assert con31["3"]["fpga"]["ball"] == "D10"
- assert con31["3"]["function_category"] == "fan_tach"
- assert con31["4"]["fpga"]["ball"] == "E10"
- assert con31["4"]["function_category"] == "pwm"
- assert "Q105" in " ".join(con31["4"]["path"])
- assert "FPGA high" in con31["4"]["polarity"]
- con54 = pins(refs["CON54"])
- assert "BMC" in refs["CON54"]["summary"]
- assert con54["1"]["fpga"]["ball"] == "B14"
- assert con54["2"]["fpga"]["ball"] == "A15"
- assert con54["3"]["fpga"]["ball"] == "B16"
- assert "open-drain" in con54["1"]["programming"]["hdl_guidance"]
- con70 = pins(refs["CON70"])
- assert "RS-485" in refs["CON70"]["summary"]
- assert con70["1"]["summary"].startswith("RS-485 A")
- assert con70["2"]["summary"].startswith("RS-485 B")
- assert "U13" in " ".join(con70["1"]["path"])
- assert all("R736 0R" in " ".join(con70[number]["path"]) for number in ("3", "4"))
- con8 = pins(refs["CON8"])
- assert "双风扇" in refs["CON8"]["summary"]
- assert con8["4"]["fpga"]["ball"] == "D2"
- assert con8["5"]["fpga"]["ball"] == "D3"
- assert con8["7"]["fpga"]["ball"] == "C4"
- assert con8["8"]["fpga"]["ball"] == "N10"
- def test_four_wire_fan_and_direct_gpio_connector_families_do_not_cross() -> None:
- refs = by_reference(load_board_data())
- con12_pin3 = pins(refs["CON12"])["3"]
- assert con12_pin3["function_category"] == "gpio"
- assert "input、output 或 inout" in con12_pin3["programming"]["hdl_guidance"]
- assert "只有真正需要双向共享" in con12_pin3["programming"]["hdl_guidance"]
- open_collector_refs = {"CON31", "CON32", "CON33", "CON34", "CON35", "CON68"}
- for reference in open_collector_refs:
- pin4 = pins(refs[reference])["4"]
- assert pin4["function_category"] == "pwm"
- assert any(item.startswith("Q") for item in pin4["path"]), reference
- assert "FPGA high" in pin4["polarity"], reference
- con33_pin4 = pins(refs["CON33"])["4"]
- assert con33_pin4["fpga"]["ball"] == "C7"
- assert "Q107" in " ".join(con33_pin4["path"])
- # V1.1 CON58/CON65 (MOTOR_STEP/DIR) are absent on V1.2; motor family is CON104+.
- assert "CON58" not in refs
- assert "CON65" not in refs
- motor_refs = [ref for ref in refs if ref.startswith("CON") and "电机" in refs[ref]["summary"]]
- assert "CON104" in motor_refs
- con104 = pins(refs["CON104"])
- assert con104["2"]["fpga"]["ball"] == "C12"
- assert con104["3"]["fpga"]["ball"] == "B12"
- assert con104["2"]["function_category"] == "motor"
- assert any(item.startswith("Q") for item in con104["2"]["path"])
- def test_remote_temperature_ptc_and_mcu_testpoint_paths_are_anchored() -> None:
- refs = by_reference(load_board_data())
- con53 = pins(refs["CON53"])
- assert "CT7428 U6" in refs["CON53"]["summary"]
- assert con53["1"]["path"][-1] == "U6.6 DP1"
- assert con53["3"]["path"][-1] == "U6.7 DN"
- assert con53["1"]["fpga"] is None
- assert con53["1"]["programming"]["status"] == "board_only"
- assert "open-drain" in con53["1"]["programming"]["hdl_guidance"]
- assert "只拉低或释放" in con53["1"]["programming"]["hdl_guidance"]
- assert "R811/R812" in " ".join(con53["1"]["programming"]["risks"])
- con84 = pins(refs["CON84"])
- con85 = pins(refs["CON85"])
- assert con84["1"]["path"][-1] == "U24.2 DP5"
- assert con85["1"]["path"][-1] == "U24.5 DP2"
- con18 = pins(refs["CON18"])
- assert "PTC1-PTC6" in refs["CON18"]["summary"]
- assert con18["1"]["fpga"]["ball"] == "F16"
- assert con18["1"]["fpga"]["board_signal"] == "HEAT1"
- assert "Q52" in " ".join(con18["1"]["path"])
- assert con18["11"]["net"] == "PTC6"
- assert con18["13"]["net"] == "PTC6"
- assert con18["11"]["fpga"]["ball"] == "R7"
- assert all(con18[number]["function_category"] == "ground" for number in ("2", "4", "6", "8", "10", "12", "14"))
- # V1.1 TP9 (GD32 PA0) is absent on V1.2; keep power TPs and LCD 3V3 TP31.
- assert "TP9" not in refs
- tp31 = pins(refs["TP31"])["1"]
- assert "3V3_LCD" in refs["TP31"]["summary"] or "LCD" in refs["TP31"]["summary"]
- assert tp31["net"] == "3V3_LCD"
- assert tp31["fpga"] is None
- assert tp31["recommendation"]["eligible"] is False
- tp2 = pins(refs["TP2"])["1"]
- tp7 = pins(refs["TP7"])["1"]
- assert tp2["net"] == "+3V3"
- assert tp7["net"] == "+3.3V"
- assert "+3V3" in refs["TP2"]["summary"]
- assert "+3.3V" in refs["TP7"]["summary"]
- def test_unverified_or_non_fpga_items_never_become_candidates_or_adc_sources() -> None:
- payload = load_board_data()
- for touchpoint in payload["touchpoints"]:
- for pin in touchpoint["pins"]:
- if (
- pin["evidence_tier"] != "cross_verified"
- or pin["fpga"] is None
- or pin["function_category"] in {"power", "ground"}
- or pin["pad_role"] != "contact"
- or pin["reserved"] is True
- or pin["fixed_load_conflict"] is True
- ):
- assert pin["recommendation"]["eligible"] is False, f"{touchpoint['reference']}.{pin['number']}"
|