| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- """The menu catalogue must match captured firmware and keep UIP separate."""
- from pathlib import Path
- import re
- import pytest
- from stl_backend.domain.amt import amt_catalog, build_amt_command
- from stl_backend.domain.firmware import catalog as uip_catalog
- from stl_backend.errors import BenchError
- def test_amt_catalog_matches_native_menu_without_importing_uip_or_help():
- raw = (Path(__file__).parent / "fixtures/live_uip1_exploration_20261023.log").read_text()
- menu = re.split(r"\[\d+\]\[AMEMDIAG #\]", raw.split("AMEMDIAG Command List:", 1)[1], maxsplit=1)[0]
- native_names = {line.strip() for line in menu.splitlines() if line.strip()}
- data = amt_catalog()
- assert len(native_names) == data["item_count"] == 27
- assert native_names == {item["name"] for item in data["items"]}
- assert "admt" in {item["id"] for item in uip_catalog()["items"]}
- assert not {"admt", "help", "?"} & native_names
- # These are valid at other firmware interfaces, not AMT parameter names.
- for name in ("admt", "help", "?"):
- with pytest.raises(BenchError, match="未知 AMT"):
- build_amt_command(name)
- def test_native_parameter_directory_does_not_invent_values_or_readback():
- items = {item["name"]: item for item in amt_catalog()["items"]}
- # Current captures support only these two bare read operations.
- assert {name for name, item in items.items() if item["access"] == "read"} == {"show", "product"}
- for item in items.values():
- assert item["source"]
- assert item["default"] is None
- assert item["choices"] == []
- # Regression: show returns a pattern, not the full effective settings.
- assert "patData" in items["show"]["label"]
- assert "完整配置" in items["show"]["description"]
- for name in ("mc", "module", "channelmask", "offset", "algomask"):
- assert items[name]["access"] == "unknown"
- assert "未确认" in items[name]["description"] or "未验证" in items[name]["description"]
- assert {name for name, item in items.items() if not item["configuration_allowed"]} == {
- "amemdiag", "amemdiag_test", "exit",
- }
|