Fix ESP32 Full Companion partition policy
This commit is contained in:
1 parent
fdf528bb27
commit
f873e51b43
5 files changed
+266
-2
No files matched your search
@@ -15,6 +15,7 @@ pio test -e native_kiss_modem # KISS modem suite
|
||||
pio test -e native -f test_webconfig_keys # a single suite
|
||||
python3 test/test_indicator_display_profile.py # Indicator RAM/scale contract
|
||||
python3 test/test_companion_terminal_profile.py # Companion CLI capability gates
|
||||
python3 test/test_esp32_full_partition.py # Full partition-preservation policy
|
||||
```
|
||||
|
||||
A green `[PASSED]` per suite means GoogleTest returned 0 (all assertions
|
||||
|
||||
@@ -12,6 +12,18 @@ fail() {
|
||||
[ "$OPTION3_BUILD_WORKERS" -eq 1 ] \
|
||||
|| fail "logging matrix permits concurrent PlatformIO target builds"
|
||||
|
||||
# The expanded-profile marker applied below must select a real, nonzero
|
||||
# boot-local setup window. Keep the build overlay, WebConfig compile-time
|
||||
# mapping, and pure timing policy tied together.
|
||||
grep -Fq \
|
||||
'static const uint32_t kFullSetupApWindowMs = 30UL * 60UL * 1000UL;' \
|
||||
src/helpers/WebConfigBatch.h \
|
||||
|| fail "Full setup-AP window is no longer exactly 30 minutes"
|
||||
grep -Fq \
|
||||
'#define WEBCONFIG_UNCONFIGURED_SETUP_TIMEOUT_MS WebConfigBatch::kFullSetupApWindowMs' \
|
||||
src/helpers/esp32/WebConfigServer.h \
|
||||
|| fail "expanded Full profile no longer enables the unconfigured-WiFi cutoff"
|
||||
|
||||
requires_esp32_arduino3_framework \
|
||||
heltec_rc32_repeater heltec_rc32_repeater \
|
||||
|| fail "RC32 omitted its Arduino-ESP32 3.x package preflight"
|
||||
@@ -331,6 +343,20 @@ for full_env in "${SUPPORTED_PIO_ENVS[@]}"; do
|
||||
fi
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *"WIFI_OTA_SEEDER=1"* ]] \
|
||||
|| fail "$full_env Full Companion omitted its WiFi runtime overlay"
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *"MESHCORE_EXPANDED_PARTITION_PROFILE=1"* ]] \
|
||||
|| fail "$full_env Full Companion omitted its expanded runtime profile"
|
||||
case "${full_env,,}" in
|
||||
sensecapindicator-espnow_companion_radio_full|\
|
||||
sensecapindicator-lora_companion_radio_full)
|
||||
[ "${MESHCORE_ESP32_FULL_PARTITION_TABLE:-}" \
|
||||
= "variants/sensecap_indicator-espnow/dual_ota_2560k_preserve_spiffs.csv" ] \
|
||||
|| fail "$full_env omitted the Indicator preserve-SPIFFS table"
|
||||
;;
|
||||
*)
|
||||
[ -z "${MESHCORE_ESP32_FULL_PARTITION_TABLE:-}" ] \
|
||||
|| fail "$full_env inherited another board's required partition table"
|
||||
;;
|
||||
esac
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *"CONFIG_ASYNC_TCP_STACK_SIZE=4096"* ]] \
|
||||
|| fail "$full_env Full Companion omitted its bounded AsyncTCP stack"
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *"CONFIG_ASYNC_TCP_RUNNING_CORE=1"* ]] \
|
||||
@@ -351,7 +377,7 @@ for full_env in "${SUPPORTED_PIO_ENVS[@]}"; do
|
||||
esac
|
||||
done
|
||||
unset PLATFORMIO_BUILD_FLAGS PLATFORMIO_BUILD_UNFLAGS \
|
||||
PLATFORMIO_BUILD_SRC_FILTER
|
||||
PLATFORMIO_BUILD_SRC_FILTER MESHCORE_ESP32_FULL_PARTITION_TABLE
|
||||
|
||||
# The bounded AsyncTCP task stack belongs to every ESP32 Full profile, including
|
||||
# expanded non-Companion builds, but must not leak into ordinary or nRF52
|
||||
@@ -785,6 +811,8 @@ expectations=" ${BUILD_EXPECTATIONS[*]} "
|
||||
|| fail "ESP32 Full contract uses no stable network-terminal evidence"
|
||||
[[ "$expectations" == *"companion.wifi_ota_seeder=OTA seeder listening on :"* ]] \
|
||||
|| fail "ESP32 Full contract omitted the WiFi seeder"
|
||||
[[ "$expectations" == *"web.unconfigured_setup_cutoff=WiFi still unconfigured after"* ]] \
|
||||
|| fail "ESP32 Full contract omitted the bounded unconfigured-WiFi window"
|
||||
[[ "$expectations" != *"Full Companion terminal listening"* ]] \
|
||||
|| fail "ESP32 Full contract still depends on optional debug logging"
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "scripts" / "esp32_full_partition.py"
|
||||
INDICATOR_PROFILE = (
|
||||
ROOT / "variants" / "sensecap_indicator-espnow" / "platformio.ini"
|
||||
)
|
||||
INDICATOR_PARTITIONS = (
|
||||
"variants/sensecap_indicator-espnow/"
|
||||
"dual_ota_2560k_preserve_spiffs.csv"
|
||||
)
|
||||
|
||||
|
||||
class FakeBoardConfig:
|
||||
def __init__(self, values):
|
||||
self.values = dict(values)
|
||||
self.updates = []
|
||||
|
||||
def get(self, key, default=None):
|
||||
return self.values.get(key, default)
|
||||
|
||||
def update(self, key, value):
|
||||
self.values[key] = value
|
||||
self.updates.append((key, value))
|
||||
|
||||
|
||||
class FakeEnvironment:
|
||||
def __init__(self, board):
|
||||
self.board = board
|
||||
|
||||
def BoardConfig(self):
|
||||
return self.board
|
||||
|
||||
|
||||
def apply_policy(
|
||||
values, *, full=True, companion=True, required_partitions=""
|
||||
):
|
||||
board = FakeBoardConfig(values)
|
||||
environment = {
|
||||
"MESHCORE_ESP32_FULL_BUILD": "1" if full else "0",
|
||||
"MESHCORE_COMPANION_RADIO_FULL": "1" if companion else "0",
|
||||
"MESHCORE_ESP32_FULL_PARTITION_TABLE": required_partitions,
|
||||
}
|
||||
output = io.StringIO()
|
||||
with mock.patch.dict(os.environ, environment, clear=False):
|
||||
with contextlib.redirect_stdout(output):
|
||||
runpy.run_path(
|
||||
str(SCRIPT),
|
||||
init_globals={
|
||||
"Import": lambda _name: None,
|
||||
"env": FakeEnvironment(board),
|
||||
},
|
||||
)
|
||||
return board, output.getvalue()
|
||||
|
||||
|
||||
class Esp32FullPartitionTest(unittest.TestCase):
|
||||
def test_indicator_full_retains_preserve_spiffs_layout(self):
|
||||
profile = INDICATOR_PROFILE.read_text()
|
||||
self.assertIn(
|
||||
f"board_build.partitions = {INDICATOR_PARTITIONS}", profile
|
||||
)
|
||||
|
||||
table = (ROOT / INDICATOR_PARTITIONS).read_text()
|
||||
self.assertIn("app0, app, ota_0, 0x10000, 0x280000", table)
|
||||
self.assertIn("spiffs, data, spiffs, 0x290000, 0x160000", table)
|
||||
self.assertIn("app1, app, ota_1, 0x400000, 0x280000", table)
|
||||
|
||||
board, output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.variant": "esp32s3",
|
||||
"build.flash_mode": "qio",
|
||||
"build.partitions": INDICATOR_PARTITIONS,
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(board.values["build.partitions"], INDICATOR_PARTITIONS)
|
||||
self.assertIn(("build.partitions", INDICATOR_PARTITIONS), board.updates)
|
||||
self.assertEqual(board.values["build.flash_mode"], "dio")
|
||||
self.assertIn(INDICATOR_PARTITIONS, output)
|
||||
|
||||
def test_absolute_indicator_partition_path_is_also_preserved(self):
|
||||
absolute = str(ROOT / INDICATOR_PARTITIONS)
|
||||
board, _output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.partitions": absolute,
|
||||
}
|
||||
)
|
||||
self.assertEqual(board.values["build.partitions"], INDICATOR_PARTITIONS)
|
||||
|
||||
def test_indicator_target_override_preserves_espnow_base_data_layout(self):
|
||||
board, _output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.partitions": "default.csv",
|
||||
},
|
||||
required_partitions=INDICATOR_PARTITIONS,
|
||||
)
|
||||
self.assertEqual(board.values["build.partitions"], INDICATOR_PARTITIONS)
|
||||
|
||||
def test_unknown_required_partition_table_fails_closed(self):
|
||||
with self.assertRaisesRegex(
|
||||
ValueError, "unsupported required Full partition table"
|
||||
):
|
||||
apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.partitions": "default.csv",
|
||||
},
|
||||
required_partitions="variants/not-a-real-layout.csv",
|
||||
)
|
||||
|
||||
def test_generic_eight_megabyte_full_still_expands(self):
|
||||
board, _output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.partitions": "default.csv",
|
||||
}
|
||||
)
|
||||
self.assertEqual(board.values["build.partitions"], "default_8MB.csv")
|
||||
|
||||
def test_capacity_only_custom_table_does_not_bypass_full_policy(self):
|
||||
board, _output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "4MB",
|
||||
"build.mcu": "esp32",
|
||||
"build.partitions": "variants/dual_ota_1536k.csv",
|
||||
}
|
||||
)
|
||||
self.assertEqual(board.values["build.partitions"], "huge_app.csv")
|
||||
|
||||
def test_tbeam_1w_factory_layout_keeps_precedence(self):
|
||||
board, _output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.variant": "lilygo_tbeam_1w",
|
||||
"build.partitions": INDICATOR_PARTITIONS,
|
||||
}
|
||||
)
|
||||
self.assertEqual(board.values["build.partitions"], "huge_app.csv")
|
||||
|
||||
def test_non_full_build_is_untouched(self):
|
||||
board, output = apply_policy(
|
||||
{
|
||||
"upload.flash_size": "8MB",
|
||||
"build.mcu": "esp32s3",
|
||||
"build.flash_mode": "qio",
|
||||
"build.partitions": INDICATOR_PARTITIONS,
|
||||
},
|
||||
full=False,
|
||||
)
|
||||
self.assertEqual(board.updates, [])
|
||||
self.assertEqual(output, "")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user