Repository navigation
ci(flash-offsets): refuse to guess the platform default; add gate tests - #1922
Merged
Merged
Conversation
`ci/check_flash_offsets.py` guards a bricking constant: the second-stage bootloader offset is ROM-defined, and #278 shipped `0x0` where the ROM loads at `0x2000`. Its docstring promises it "never silently passes", but two argument paths made it fabricate the answer: - a boards.txt with no sibling `platform.txt` at all, and - a `platform.txt` that does not declare `build.bootloader_addr` Both fell through to a hard-coded `DEFAULT_BOOTLOADER_ADDR = "0x1000"`, so a chip that relies on the platform default was reported as matching an authoritative value that came from nowhere. Reproduced on main `672bc685` with a 9-config fixture: exit 0, "All 9 esp32 config(s) match". Both are hard failures now -- an unresolved default is an unverifiable chip, not a pass. `parse_platform_default` returns `None` when the key is absent or no platform.txt exists, `authoritative_offset` refuses to resolve a default-reliant chip without it, and the failure names which of the two situations occurred. The one legitimate pass (a real default, or an explicit `<chip>.build.bootloader_addr`) is unchanged: the real repo run against the pioarduino 3.3.7 tag and against a cached 3.3.12 framework is byte-identical to main's output, rc 0. Also split `main` (which carried `# noqa: C901`) into `parse_args` / `resolve_source` / `evaluate` / `report_lines` so the check is drivable without a subprocess, and gave `--boards-txt` with no value a clear error instead of "Unknown argument". New `ci/test_check_flash_offsets.py` (28 tests) covers the parsers, per-config failures, both fail-open regressions, every real config's partitions/firmware pins, and drives the real script as a subprocess in a repo-shaped temp tree (so `configs_dir()` discovery is exercised). Registered in both entry points; `untested` 6 -> 5, `MAX_UNTESTED` 6 -> 5. Real output: 28/28 OK; hosted self-test set 186 -> 214 OK; `gate_script_coverage --budget 5` clean; `check_python_complexity` clean; ruff + `ruff format --check` clean; RED proven by restoring the `"0x1000"` fallback in place (5 tests fail), then restored.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ci/check_flash_offsets.pyverifies the ESP32 bootloader offset — a ROM-defined constant where a wrong value is a brick (#278 shipped0x0where the ROM loads at0x2000). Its docstring promises it "never silently passes". Two argument paths broke that promise by fabricating the authoritative value.The two fail-open paths (reproduced on
main672bc685)Both fell through to a hard-coded
DEFAULT_BOOTLOADER_ADDR = "0x1000":boards.txtwith no siblingplatform.txt.--boards-txt/$FBUILD_ESP32_BOARDS_TXTreadplatform.txtonlyif platform_path.exists(), else""→parse_platform_default("")returned the constant.platform.txtthat does not declarebuild.bootloader_addr. Same fallthrough.Both were reported as verified against an authority. Measured with a 9-config fixture (
esp32/esp32s2on the default, the rest explicit):After:
An unresolved default is an unverifiable chip, not a pass.
parse_platform_defaultnow returnsNone,authoritative_offsetrefuses to resolve a default-reliant chip without it, and the message says which of the two situations occurred.No behaviour change on the real repo
--boards-txt <cached 3.3.12 framework>and--download(the pioarduino3.3.7tag CI uses, which does declarebuild.bootloader_addr=0x1000) both produce output byte-identical tomain's, rc 0 — all 9 configs PASS. This is not a false-RED risk for theDylint policyjob.Structure
maincarried a# noqa: C901, so it is split intoparse_args/resolve_source/evaluate/report_lines— the check is now drivable in-process.--boards-txtwith no value now says "--boards-txt needs a path" instead of "Unknown argument".Tests
ci/test_check_flash_offsets.py, 28 tests: parsers and offset normalisation; every per-config failure face (stale offset, missingbootloaderkey, partition/firmware drift, chip unknown toboards.txt); both fail-open regressions as named cases; every real config'spartitions/firmwarepins; and end-to-end runs of the real script as a subprocess in a repo-shaped temp tree, soconfigs_dir()'s relative discovery is exercised.RED proven by restoring the old
return "0x1000"fallback in place: 5 tests fail (parse_platform_default(None), both fail-open regressions, the e2e missing-platform case, and the changed-upstream-default case), then restored → 28/28 OK.Ratchet
ci/gate_script_tests.toml:check_flash_offsetsleavesuntested(6 → 5) and declares its test;MAX_UNTESTED6 → 5; registered in both entry points (ci/local_suites.pyDRIFT_UNITTEST_MODULES+ theci-workflow-drift.ymlunittest command) in matching order.Remaining untested gates:
build_backend,build_qemu_linux_runtime,cancel_superseded,check_dylint_allowlists,validate_boards.Closes nothing — part of the gate-coverage burn-down (#1915).