tests: Update pytest scenarios with sysbuild paths

Updated sample to test DFU with mcumgr.
Use paths to default domain build dir from device_config.

Signed-off-by: Grzegorz Chwierut <grzegorz.chwierut@nordicsemi.no>
This commit is contained in:
Grzegorz Chwierut 2024-05-24 16:04:25 +02:00 committed by Henrik Brix Andersen
commit 76ff3afffe
2 changed files with 14 additions and 12 deletions

View file

@ -14,7 +14,7 @@ from utils import (
check_with_shell_command,
check_with_mcumgr_command,
)
from test_upgrade import create_signed_image, PROJECT_NAME
from test_upgrade import create_signed_image
logger = logging.getLogger(__name__)
@ -34,14 +34,15 @@ def test_downgrade_prevention(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
6) Verify that the original application is booted (version 1.1.1)
"""
origin_version = find_in_config(
Path(dut.device_config.build_dir) / PROJECT_NAME / 'zephyr' / '.config',
Path(dut.device_config.app_build_dir) / 'zephyr' / '.config',
'CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION'
)
check_with_shell_command(shell, origin_version)
assert origin_version != '0.0.0+0'
logger.info('Prepare upgrade image with lower version')
image_to_test = create_signed_image(dut.device_config.build_dir, '0.0.0+0')
image_to_test = create_signed_image(dut.device_config.build_dir,
dut.device_config.app_build_dir, '0.0.0+0')
logger.info('Upload image with mcumgr')
dut.disconnect()

View file

@ -18,10 +18,9 @@ from utils import (
)
logger = logging.getLogger(__name__)
PROJECT_NAME = 'with_mcumgr'
def create_signed_image(build_dir: Path, version: str) -> Path:
def create_signed_image(build_dir: Path, app_build_dir: Path, version: str) -> Path:
image_to_test = Path(build_dir) / 'test_{}.signed.bin'.format(
version.replace('.', '_').replace('+', '_'))
origin_key_file = find_in_config(
@ -29,7 +28,7 @@ def create_signed_image(build_dir: Path, version: str) -> Path:
'CONFIG_BOOT_SIGNATURE_KEY_FILE'
)
west_sign_with_imgtool(
build_dir=Path(build_dir) / PROJECT_NAME,
build_dir=Path(app_build_dir),
output_bin=image_to_test,
key_file=Path(origin_key_file),
version=version
@ -62,7 +61,8 @@ def test_upgrade_with_confirm(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
"""
logger.info('Prepare upgrade image')
new_version = '0.0.2+0'
image_to_test = create_signed_image(dut.device_config.build_dir, new_version)
image_to_test = create_signed_image(dut.device_config.build_dir,
dut.device_config.app_build_dir, new_version)
logger.info('Upload image with mcumgr')
dut.disconnect()
@ -111,12 +111,13 @@ def test_upgrade_with_revert(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
8) Verify that MCUboot reverts update
"""
origin_version = find_in_config(
Path(dut.device_config.build_dir) / PROJECT_NAME / 'zephyr' / '.config',
Path(dut.device_config.app_build_dir) / 'zephyr' / '.config',
'CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION'
)
logger.info('Prepare upgrade image')
new_version = '0.0.3+0'
image_to_test = create_signed_image(dut.device_config.build_dir, new_version)
image_to_test = create_signed_image(dut.device_config.build_dir,
dut.device_config.app_build_dir, new_version)
logger.info('Upload image with mcumgr')
dut.disconnect()
@ -178,14 +179,14 @@ def test_upgrade_signature(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr, key
key_file = Path(origin_key_file).parent / key_file
assert key_file.is_file()
assert not key_file.samefile(origin_key_file)
image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin'
image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin'
logger.info('Sign second image with an invalid key')
else:
image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin'
image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin'
logger.info('Sign second imagewith no key')
west_sign_with_imgtool(
build_dir=Path(dut.device_config.build_dir) / PROJECT_NAME,
build_dir=Path(dut.device_config.app_build_dir),
output_bin=image_to_test,
key_file=key_file,
version='0.0.3+4' # must differ from the origin version, if not then hash is not updated