Skip to content

Commit 76ff3af

Browse files
gchwierhenrikbrixandersen
authored andcommitted
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 <[email protected]>
1 parent f52f08f commit 76ff3af

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

tests/boot/with_mcumgr/pytest/test_downgrade_prevention.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
check_with_shell_command,
1515
check_with_mcumgr_command,
1616
)
17-
from test_upgrade import create_signed_image, PROJECT_NAME
17+
from test_upgrade import create_signed_image
1818

1919

2020
logger = logging.getLogger(__name__)
@@ -34,14 +34,15 @@ def test_downgrade_prevention(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
3434
6) Verify that the original application is booted (version 1.1.1)
3535
"""
3636
origin_version = find_in_config(
37-
Path(dut.device_config.build_dir) / PROJECT_NAME / 'zephyr' / '.config',
37+
Path(dut.device_config.app_build_dir) / 'zephyr' / '.config',
3838
'CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION'
3939
)
4040
check_with_shell_command(shell, origin_version)
4141
assert origin_version != '0.0.0+0'
4242

4343
logger.info('Prepare upgrade image with lower version')
44-
image_to_test = create_signed_image(dut.device_config.build_dir, '0.0.0+0')
44+
image_to_test = create_signed_image(dut.device_config.build_dir,
45+
dut.device_config.app_build_dir, '0.0.0+0')
4546

4647
logger.info('Upload image with mcumgr')
4748
dut.disconnect()

tests/boot/with_mcumgr/pytest/test_upgrade.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
)
1919

2020
logger = logging.getLogger(__name__)
21-
PROJECT_NAME = 'with_mcumgr'
2221

2322

24-
def create_signed_image(build_dir: Path, version: str) -> Path:
23+
def create_signed_image(build_dir: Path, app_build_dir: Path, version: str) -> Path:
2524
image_to_test = Path(build_dir) / 'test_{}.signed.bin'.format(
2625
version.replace('.', '_').replace('+', '_'))
2726
origin_key_file = find_in_config(
2827
Path(build_dir) / 'mcuboot' / 'zephyr' / '.config',
2928
'CONFIG_BOOT_SIGNATURE_KEY_FILE'
3029
)
3130
west_sign_with_imgtool(
32-
build_dir=Path(build_dir) / PROJECT_NAME,
31+
build_dir=Path(app_build_dir),
3332
output_bin=image_to_test,
3433
key_file=Path(origin_key_file),
3534
version=version
@@ -62,7 +61,8 @@ def test_upgrade_with_confirm(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
6261
"""
6362
logger.info('Prepare upgrade image')
6463
new_version = '0.0.2+0'
65-
image_to_test = create_signed_image(dut.device_config.build_dir, new_version)
64+
image_to_test = create_signed_image(dut.device_config.build_dir,
65+
dut.device_config.app_build_dir, new_version)
6666

6767
logger.info('Upload image with mcumgr')
6868
dut.disconnect()
@@ -111,12 +111,13 @@ def test_upgrade_with_revert(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr):
111111
8) Verify that MCUboot reverts update
112112
"""
113113
origin_version = find_in_config(
114-
Path(dut.device_config.build_dir) / PROJECT_NAME / 'zephyr' / '.config',
114+
Path(dut.device_config.app_build_dir) / 'zephyr' / '.config',
115115
'CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION'
116116
)
117117
logger.info('Prepare upgrade image')
118118
new_version = '0.0.3+0'
119-
image_to_test = create_signed_image(dut.device_config.build_dir, new_version)
119+
image_to_test = create_signed_image(dut.device_config.build_dir,
120+
dut.device_config.app_build_dir, new_version)
120121

121122
logger.info('Upload image with mcumgr')
122123
dut.disconnect()
@@ -178,14 +179,14 @@ def test_upgrade_signature(dut: DeviceAdapter, shell: Shell, mcumgr: MCUmgr, key
178179
key_file = Path(origin_key_file).parent / key_file
179180
assert key_file.is_file()
180181
assert not key_file.samefile(origin_key_file)
181-
image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin'
182+
image_to_test = Path(dut.device_config.build_dir) / 'test_invalid_key.bin'
182183
logger.info('Sign second image with an invalid key')
183184
else:
184-
image_to_test = image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin'
185+
image_to_test = Path(dut.device_config.build_dir) / 'test_no_key.bin'
185186
logger.info('Sign second imagewith no key')
186187

187188
west_sign_with_imgtool(
188-
build_dir=Path(dut.device_config.build_dir) / PROJECT_NAME,
189+
build_dir=Path(dut.device_config.app_build_dir),
189190
output_bin=image_to_test,
190191
key_file=key_file,
191192
version='0.0.3+4' # must differ from the origin version, if not then hash is not updated

0 commit comments

Comments
 (0)