From 6543d10c5a8a53d27f29a8d08ac2b7a117db3810 Mon Sep 17 00:00:00 2001 From: divemba Date: Tue, 1 Sep 2026 19:48:48 -0500 Subject: [PATCH 1/2] fix: board_capacity drops known values on partial override A board YAML that overrode only one of flash_size/ram_size caused the other to report as unknown, even though the reference table had a value for the named board family. Missing fields are now backfilled from the reference table instead of being discarded. --- ebuild/build/footprint.py | 42 ++++++++++++++++++++---------------- tests/unit/test_footprint.py | 11 ++++++++++ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/ebuild/build/footprint.py b/ebuild/build/footprint.py index afd477e4..5651aad3 100644 --- a/ebuild/build/footprint.py +++ b/ebuild/build/footprint.py @@ -201,25 +201,29 @@ def measure(artifact: Path, size_tool: Optional[str] = None) -> Footprint: def board_capacity(board: Optional[str], - board_config: Optional[dict] = None - ) -> Tuple[Optional[int], Optional[int]]: - """Flash and RAM capacity for a board, or (None, None) when unknown. - - A project's own board YAML wins over the reference table: `memory.flash_size` - and `memory.ram_size` are what the hardware descriptions in `hardware/board/` - already use. - """ - if board_config: - memory = board_config.get("memory") or {} - flash = _as_bytes(memory.get("flash_size")) - ram = _as_bytes(memory.get("ram_size")) - if flash or ram: - return flash, ram - if board: - found = _REFERENCE_CAPACITY.get(board.lower()) - if found: - return found - return None, None + board_config: Optional[dict] = None + ) -> Tuple[Optional[int], Optional[int]]: + """Flash and RAM capacity for a board, or (None, None) when unknown. + + + A project's own board YAML wins over the reference table: `memory.flash_size` + and `memory.ram_size` are what the hardware descriptions in `hardware/board/` + already use. + """ + reference = _REFERENCE_CAPACITY.get(board.lower()) if board else None + if board_config: + memory = board_config.get("memory") or {} + flash = _as_bytes(memory.get("flash_size")) + ram = _as_bytes(memory.get("ram_size")) + if flash or ram: + if flash is None and reference: + flash = reference[0] + if ram is None and reference: + ram = reference[1] + return flash, ram + if reference: + return reference + return None, None def _as_bytes(value) -> Optional[int]: diff --git a/tests/unit/test_footprint.py b/tests/unit/test_footprint.py index 54508539..e10483a1 100644 --- a/tests/unit/test_footprint.py +++ b/tests/unit/test_footprint.py @@ -153,6 +153,17 @@ def test_a_zero_or_unparseable_size_is_not_a_capacity(self): def test_a_board_config_without_memory_falls_back(self): assert board_capacity("stm32f4", {"board_name": "x"})[0] == 1024 * 1024 + def test_a_partial_override_fills_the_rest_from_the_reference_part(self): + """A board YAML that only overrides RAM (say, because it was fitted + with extra SRAM) should not lose the reference flash figure for the + same part.""" + cfg = {"memory": {"ram_size": 320 * 1024}} + assert board_capacity("stm32f4", cfg) == (1024 * 1024, 320 * 1024) + + + cfg = {"memory": {"flash_size": "0x40000"}} + assert board_capacity("stm32f4", cfg) == (262144, 192 * 1024) + class TestReport: def test_percentages_appear_only_with_a_known_capacity(self): From acb7d342badbe8105a2bd3d18744f4b9a1549f02 Mon Sep 17 00:00:00 2001 From: divemba Date: Tue, 1 Sep 2026 19:50:34 -0500 Subject: [PATCH 2/2] chore: remove duplicate marker declarations in pytest.ini --- pytest.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 4ace1581..c6dd37e1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -17,8 +17,6 @@ markers = integration: end-to-end tests spanning multiple repos cross_repo: cross-repo integration tests requiring sibling repos qemu: tests requiring QEMU emulator (skipped if QEMU not installed) - cross_repo: cross-repo integration tests requiring sibling repos - qemu: tests requiring QEMU emulator (skipped if QEMU not installed) needs_yaml: tests that import modules requiring pyyaml # ── Output ───────────────────────────────────────────────────