Skip to content

Commit 7816cda

Browse files
committed
samples: mpu_test: verify sample using pytest
Verify sample using pytest instead of just building the sample. Signed-off-by: Anas Nashif <[email protected]>
1 parent 6a6512f commit 7816cda

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2023 Nordic Semiconductor ASA
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import logging
6+
import pytest
7+
import re
8+
from twister_harness import Shell
9+
10+
logger = logging.getLogger(__name__)
11+
12+
TESTDATA = [
13+
('mpu mtest 1', 'The value is: 0x.*'),
14+
('mpu mtest 2', 'The value is: 0x.*'),
15+
]
16+
@pytest.mark.parametrize('command,expected', TESTDATA)
17+
def test_shell_harness(shell: Shell, command, expected):
18+
logger.info('send "help" command')
19+
lines = shell.exec_command(command)
20+
match = False
21+
for line in lines:
22+
if re.match(expected, line):
23+
match = True
24+
break
25+
26+
assert match, 'expected response not found'
27+
logger.info('response is valid')

samples/arch/mpu/mpu_test/sample.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ tests:
44
sample.mpu.mpu_test:
55
arch_allow: arm
66
filter: CONFIG_CPU_HAS_MPU and not CONFIG_ARM64
7-
tags: mpu
8-
harness: keyboard
7+
tags:
8+
- mpu
9+
harness: pytest

0 commit comments

Comments
 (0)