From 141f7fa42750279b33d41e23c120a6c1373bf994 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 27 Jan 2025 13:59:46 +0000 Subject: [PATCH] tests: boot: with_mcumgr: Add swap using offset test Adds a variation of the test which tests swap using offset mode, based on the swap using move test Signed-off-by: Jamie McCrae --- tests/boot/with_mcumgr/pytest/test_upgrade.py | 20 ++++++++--- tests/boot/with_mcumgr/testcase.yaml | 33 ++++++++++++------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/tests/boot/with_mcumgr/pytest/test_upgrade.py b/tests/boot/with_mcumgr/pytest/test_upgrade.py index f7d74d62dba..733bd40f478 100755 --- a/tests/boot/with_mcumgr/pytest/test_upgrade.py +++ b/tests/boot/with_mcumgr/pytest/test_upgrade.py @@ -32,6 +32,13 @@ def create_signed_image(build_dir: Path, app_build_dir: Path, version: str) -> P return image_to_test +def get_upgrade_string_to_verify(build_dir: Path) -> str: + sysbuild_config = Path(build_dir) / 'zephyr' / '.config' + if find_in_config(sysbuild_config, 'SB_CONFIG_MCUBOOT_MODE_SWAP_USING_OFFSET'): + return 'Starting swap using offset algorithm' + return 'Starting swap using move algorithm' + + def clear_buffer(dut: DeviceAdapter) -> None: disconnect = False if not dut.is_device_connected(): @@ -71,9 +78,10 @@ def test_upgrade_with_confirm(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): dut.connect() output = dut.readlines_until('Launching primary slot application') + upgrade_string_to_verify = get_upgrade_string_to_verify(dut.device_config.build_dir) match_lines(output, [ 'Swap type: test', - 'Starting swap using move algorithm' + upgrade_string_to_verify ]) logger.info('Verify new APP is booted') check_with_shell_command(shell, new_version, swap_type='test') @@ -87,7 +95,7 @@ def test_upgrade_with_confirm(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): dut.connect() output = dut.readlines_until('Launching primary slot application') match_no_lines(output, [ - 'Starting swap using move algorithm' + upgrade_string_to_verify ]) logger.info('Verify new APP is still booted') check_with_shell_command(shell, new_version) @@ -126,9 +134,10 @@ def test_upgrade_with_revert(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): dut.connect() output = dut.readlines_until('Launching primary slot application') + upgrade_string_to_verify = get_upgrade_string_to_verify(dut.device_config.build_dir) match_lines(output, [ 'Swap type: test', - 'Starting swap using move algorithm' + upgrade_string_to_verify ]) logger.info('Verify new APP is booted') check_with_shell_command(shell, new_version, swap_type='test') @@ -142,7 +151,7 @@ def test_upgrade_with_revert(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr): output = dut.readlines_until('Launching primary slot application') match_lines(output, [ 'Swap type: revert', - 'Starting swap using move algorithm' + upgrade_string_to_verify ]) logger.info('Verify that MCUboot reverts update') check_with_shell_command(shell, origin_version) @@ -202,5 +211,6 @@ def test_upgrade_signature(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr, key dut.connect() output = dut.readlines_until('Launching primary slot application') - match_no_lines(output, ['Starting swap using move algorithm']) + upgrade_string_to_verify = get_upgrade_string_to_verify(dut.device_config.build_dir) + match_no_lines(output, [upgrade_string_to_verify]) match_lines(output, ['Image in the secondary slot is not valid']) diff --git a/tests/boot/with_mcumgr/testcase.yaml b/tests/boot/with_mcumgr/testcase.yaml index 0500bbaddf5..b4b23be1600 100644 --- a/tests/boot/with_mcumgr/testcase.yaml +++ b/tests/boot/with_mcumgr/testcase.yaml @@ -1,31 +1,32 @@ common: sysbuild: true platform_allow: - - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf54l15dk/nrf54l15/cpuapp - nrf9160dk/nrf9160 - nucleo_wba55cg - integration_platforms: - - nrf52840dk/nrf52840 timeout: 600 slow: true + tags: + - pytest + - mcuboot + - mcumgr tests: boot.with_mcumgr.test_upgrade: - tags: - - pytest - - mcuboot - - mcumgr + platform_allow: + - nrf52840dk/nrf52840 + integration_platforms: + - nrf52840dk/nrf52840 harness: pytest harness_config: pytest_root: - "pytest/test_upgrade.py" boot.with_mcumgr.test_downgrade_prevention: - tags: - - pytest - - mcuboot - - mcumgr + platform_allow: + - nrf52840dk/nrf52840 + integration_platforms: + - nrf52840dk/nrf52840 harness: pytest harness_config: pytest_root: @@ -34,3 +35,13 @@ tests: - mcuboot_CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y extra_configs: - CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="1.1.1+1" + + boot.with_mcumgr.test_upgrade.swap_using_offset: + integration_platforms: + - nrf5340dk/nrf5340/cpuapp + harness: pytest + harness_config: + pytest_root: + - "pytest/test_upgrade.py" + extra_args: + - SB_CONFIG_MCUBOOT_MODE_SWAP_USING_OFFSET=y