Keep only local OTA target names in reduced RAK builds
This commit is contained in:
1 parent
0cba0c3afa
commit
308fec1162
8 files changed
+89
-2
No files matched your search
@@ -1900,11 +1900,17 @@ verify_reduced_sensor_flags() {
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *-UENV_INCLUDE_BME280* ]] \
|
||||
|| fail "$env_name did not omit environmental sensors"
|
||||
if [ "$expect_ina" = 1 ]; then
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *-DMESH_OTA_LOCAL_TARGET_NAME_ONLY=1* ]] \
|
||||
|| fail "$env_name retained the all-board OTA name catalog"
|
||||
[[ " ${BUILD_REDUCTIONS[*]} " == *"ota target-name catalog omitted"* ]] \
|
||||
|| fail "$env_name did not declare its OTA name reduction"
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *-DENV_INCLUDE_INA219=1* ]] \
|
||||
|| fail "$env_name did not retain INA monitor support"
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" != *-UENV_INCLUDE_INA219* ]] \
|
||||
|| fail "$env_name both retained and omitted INA monitor support"
|
||||
else
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" != *MESH_OTA_LOCAL_TARGET_NAME_ONLY* ]] \
|
||||
|| fail "$env_name lost OTA names outside the reduced RAK profile"
|
||||
[[ "$PLATFORMIO_BUILD_FLAGS" == *-UENV_INCLUDE_INA219* ]] \
|
||||
|| fail "$env_name incorrectly retained INA monitor support"
|
||||
fi
|
||||
@@ -1914,6 +1920,10 @@ verify_reduced_sensor_flags \
|
||||
RAK_3401_repeater_lora_ota_no_external_sensors 1
|
||||
verify_reduced_sensor_flags \
|
||||
RAK_3401_room_server_lora_ota_no_external_sensors 1
|
||||
verify_reduced_sensor_flags \
|
||||
RAK_4631_repeater_lora_ota_no_external_sensors 1
|
||||
verify_reduced_sensor_flags \
|
||||
RAK_4631_sensor_lora_ota_no_external_sensors 1
|
||||
verify_reduced_sensor_flags \
|
||||
Heltec_t114_repeater_lora_ota_no_external_sensors 0
|
||||
|
||||
|
||||
@@ -67,6 +67,26 @@ class Nrf52FlashTrimTest(unittest.TestCase):
|
||||
self.assertNotIn("SSD1306_NO_SPLASH", defines)
|
||||
self.assertEqual(TRIM.flag_defines("-DMESH_NRF52_FLASH_TRIM=1 -UMESH_NRF52_FLASH_TRIM")["MESH_NRF52_FLASH_TRIM"], None)
|
||||
|
||||
def test_local_names_honor_overlay_identity_and_explicit_defines(self):
|
||||
flags = ('-DMESH_OTA_LOCAL_TARGET_NAME_ONLY=1 '
|
||||
'-DMOTA_TARGET_ID=0x29a0da19 '
|
||||
'-DOTA_VARIANT=\'"RAK_4631_repeater_lora_ota_no_external_sensors"\'')
|
||||
defines = self.policy(flags=flags)
|
||||
self.assertEqual(defines["OTA_TARGET_NAME_TABLE"], 0)
|
||||
self.assertEqual(defines["OTA_LOCAL_TARGET_ID"], "0x29a0da19")
|
||||
self.assertEqual(defines["OTA_LOCAL_TARGET_NAME"], "OTA_VARIANT")
|
||||
explicit = self.policy(flags=flags + ' -DOTA_TARGET_NAME_TABLE=1 '
|
||||
'-DOTA_LOCAL_TARGET_ID=7 -DOTA_LOCAL_TARGET_NAME=custom_name')
|
||||
for name in ("OTA_TARGET_NAME_TABLE", "OTA_LOCAL_TARGET_ID", "OTA_LOCAL_TARGET_NAME"):
|
||||
self.assertNotIn(name, explicit)
|
||||
for flags in ("", "-DMESH_OTA_LOCAL_TARGET_NAME_ONLY=0"):
|
||||
self.assertNotIn("OTA_TARGET_NAME_TABLE", self.policy(flags=flags))
|
||||
|
||||
def test_local_names_do_not_change_companion_or_unqualified_roles(self):
|
||||
for options in (dict(name="RAK_4631_companion_radio_full"),
|
||||
dict(role="custom"), dict(platform="espressif32", mcu="esp32")):
|
||||
self.assertEqual(self.policy(flags="-DMESH_OTA_LOCAL_TARGET_NAME_ONLY=1", **options), {})
|
||||
|
||||
def test_cc310_archive_is_exact_and_requires_supported_mcu_and_enabled_crypto(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
archive = Path(temp_dir) / "libraries/Adafruit_nRFCrypto" / TRIM.CC310_ARCHIVE
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
"""All OTA names survive front coding; original Companion API stays unchanged."""
|
||||
import re
|
||||
import os
|
||||
import configparser
|
||||
import importlib.util
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -237,6 +239,29 @@ class OtaTargetNameTest(unittest.TestCase):
|
||||
f'-DOTA_LOCAL_TARGET_NAME="{local_name}"',
|
||||
], ids), [local_name, "?", "?"])
|
||||
|
||||
def test_reduced_rak_policy_compiles_with_exact_local_names_and_ids(self):
|
||||
spec = importlib.util.spec_from_file_location("ota_name_trim", ROOT / "scripts/nrf52_flash_trim.py")
|
||||
trim = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(trim)
|
||||
for board, suffix in (("3401", ""), ("4631", ""),
|
||||
("4631", "_bridge_rs232_serial1"), ("4631", "_bridge_rs232_serial2")):
|
||||
target = f"RAK_{board}_repeater{suffix}_lora_ota_no_external_sensors"
|
||||
config = configparser.ConfigParser(interpolation=None, inline_comment_prefixes=(";",))
|
||||
config.read(ROOT / f"variants/rak{board}/platformio.ini")
|
||||
flags = config["env:" + target]["build_flags"]
|
||||
# Interpolated hardware flags do not influence the name policy.
|
||||
flags = re.sub(r"\$\{[^}]+\}", "", flags)
|
||||
target_id = gen_targets.ml.target_id_for_env(target)
|
||||
definitions = trim.flag_defines(flags)
|
||||
definitions.update(trim.trim_policy("nordicnrf52", "nrf52840", target,
|
||||
"+<../examples/simple_repeater>", flags))
|
||||
name_flags = [f"-D{name}={value}" for name, value in definitions.items()
|
||||
if name in ("OTA_TARGET_NAME_TABLE", "OTA_TARGET_NAME_FRONT_CODED",
|
||||
"OTA_LOCAL_TARGET_ID", "OTA_LOCAL_TARGET_NAME")]
|
||||
with self.subTest(target=target):
|
||||
self.assertEqual(self.compile_and_lookup(name_flags,
|
||||
[target_id, self.rows[0][0], 0]), [target, "?", "?"])
|
||||
|
||||
def test_cpp_decoder_fails_closed_on_invalid_records_and_trailing_bytes(self):
|
||||
from zopfli_compress import raw_deflate_compress
|
||||
rows = gen_targets.target_rows(["hello"])
|
||||
|
||||
Reference in new issue
Block a user