Skip to content

Commit bc0ead7

Browse files
gchwierrlubos
authored andcommitted
tests: kmu: Added no_reset fixture in provisioning tests
Updated tests/subsys/kmu tests with `no_reset` fixture. This fixtures adds `--no-reset` argument to west flash, to not reset device after flashing. Works only with pytest-harness. Signed-off-by: Grzegorz Chwierut <[email protected]>
1 parent 525ff2c commit bc0ead7

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

tests/subsys/kmu/pytest/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
import pytest
55
import logging
66

7+
from twister_harness.device.device_adapter import DeviceAdapter
8+
from twister_harness.fixtures import determine_scope
9+
710
logger = logging.getLogger(__name__)
811

912

1013
@pytest.fixture(scope='function', autouse=True)
1114
def test_log(request: pytest.FixtureRequest):
1215
logging.info("========= Test '{}' STARTED".format(request.node.nodeid))
16+
17+
18+
@pytest.fixture(scope=determine_scope)
19+
def no_reset(device_object: DeviceAdapter):
20+
"""Do not reset after flashing."""
21+
device_object.device_config.west_flash_extra_args.append("--no-reset")
22+
yield
23+
device_object.device_config.west_flash_extra_args.remove("--no-reset")

tests/subsys/kmu/pytest/test_kmu_provision.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
logger = logging.getLogger(__name__)
2020

2121

22+
@pytest.mark.usefixtures("no_reset")
2223
@pytest.mark.parametrize(
2324
'test_option', ['one_key', 'three_keys_second_used', 'three_keys_last_used']
2425
)
@@ -62,6 +63,7 @@ def test_kmu_use_key_from_config(dut: DeviceAdapter, test_option):
6263
logger.info("Passed: Booted successfully after provisioning the same key that was used during building")
6364

6465

66+
@pytest.mark.usefixtures("no_reset")
6567
def test_kmu_use_wrong_key(dut: DeviceAdapter):
6668
"""
6769
Upload keys using west ncs-provision command,

tests/subsys/kmu/pytest/test_kmu_revoke_in_app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
logger = logging.getLogger(__name__)
1616

1717

18+
@pytest.mark.usefixtures("no_reset")
1819
def test_kmu_policy_revokable(dut: DeviceAdapter):
1920
"""
2021
Upload keys using 'revokable' policy,
@@ -50,6 +51,7 @@ def test_kmu_policy_revokable(dut: DeviceAdapter):
5051
logger.info("Passed: not booted with revoked keys")
5152

5253

54+
@pytest.mark.usefixtures("no_reset")
5355
def test_kmu_policy_lock(dut: DeviceAdapter):
5456
"""
5557
Upload keys using 'lock' policy,

tests/subsys/kmu/pytest/test_kmu_verify_keys_in_app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import annotations
55

66
import logging
7+
import pytest
78

89
from pathlib import Path
910
from twister_harness import DeviceAdapter
@@ -17,6 +18,7 @@
1718
logger = logging.getLogger(__name__)
1819

1920

21+
@pytest.mark.usefixtures("no_reset")
2022
def test_kmu_correct_keys_uploaded(dut: DeviceAdapter):
2123
"""
2224
Upload valid keys to DUT using west ncs-provission command
@@ -46,6 +48,7 @@ def test_kmu_correct_keys_uploaded(dut: DeviceAdapter):
4648
])
4749

4850

51+
@pytest.mark.usefixtures("no_reset")
4952
def test_kmu_wrong_keys_uploaded(dut: DeviceAdapter):
5053
"""
5154
Upload two wrong keys to DUT using west ncs-provission command

0 commit comments

Comments
 (0)