Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions samples/arch/mpu/mpu_test/pytest/test_mpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0

import logging
import pytest
import re
from twister_harness import Shell

logger = logging.getLogger(__name__)

TESTDATA = [
('mpu mtest 1', 'The value is: 0x.*'),
('mpu mtest 2', 'The value is: 0x.*'),
]
@pytest.mark.parametrize('command,expected', TESTDATA)
def test_shell_harness(shell: Shell, command, expected):
logger.info('send "help" command')
lines = shell.exec_command(command)
match = False
for line in lines:
if re.match(expected, line):
match = True
break

assert match, 'expected response not found'
logger.info('response is valid')
5 changes: 3 additions & 2 deletions samples/arch/mpu/mpu_test/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ tests:
sample.mpu.mpu_test:
arch_allow: arm
filter: CONFIG_CPU_HAS_MPU and not CONFIG_ARM64
tags: mpu
harness: keyboard
tags:
- mpu
harness: pytest
25 changes: 25 additions & 0 deletions samples/drivers/uart/echo_bot/pytest/test_keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0

import logging
import pytest
from twister_harness import DeviceAdapter
import re

logger = logging.getLogger(__name__)

TESTDATA = [
('zephyr', 'Echo: zephyr'),
('console', 'Echo: console'),
]
@pytest.mark.parametrize('command,expected', TESTDATA)
def test_echo_bot(dut: DeviceAdapter, command, expected):
timeout = 10.0
command_ext = f'{command}\n\n'
regex_expected = f'.*{re.escape(expected)}'
dut.clear_buffer()
dut.write(command_ext.encode())
lines: list[str] = []
lines.extend(dut.readlines_until(regex=regex_expected, timeout=timeout, print_output=True))
assert expected in lines, 'expected response not found'
2 changes: 1 addition & 1 deletion samples/drivers/uart/echo_bot/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ tests:
filter: CONFIG_SERIAL and
CONFIG_UART_INTERRUPT_DRIVEN and
dt_chosen_enabled("zephyr,shell-uart")
harness: keyboard
harness: pytest
24 changes: 24 additions & 0 deletions samples/subsys/console/getline/pytest/test_keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0

import logging
import pytest
from twister_harness import DeviceAdapter
import re

logger = logging.getLogger(__name__)

TESTDATA = [
('Zephyr is great', 'line: Zephyr is great'),
('This is a test', 'line: This is a test'),
]
@pytest.mark.parametrize('command,expected', TESTDATA)
def test_getline(dut: DeviceAdapter, command, expected):
command_ext = f'{command}\n\n'
regex_expected = f'.*{re.escape(expected)}'
dut.clear_buffer()
dut.write(command_ext.encode())
lines: list[str] = []
lines.extend(dut.readlines_until(regex=regex_expected, timeout=10.0, print_output=True))
assert expected in lines, 'expected response not found'
2 changes: 1 addition & 1 deletion samples/subsys/console/getline/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ tests:
- mps2/an385
filter: CONFIG_UART_CONSOLE and CONFIG_SERIAL_SUPPORT_INTERRUPT
tags: console
harness: keyboard
harness: pytest
33 changes: 6 additions & 27 deletions tests/drivers/uart/uart_basic_api/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,58 +1,37 @@
common:
harness: keyboard
filter: CONFIG_UART_CONSOLE
tags:
- drivers
- uart
tests:
drivers.uart.basic_api:
tags:
- drivers
- uart
filter: CONFIG_UART_CONSOLE
harness: keyboard
integration_platforms:
- mps2/an385
drivers.uart.basic_api.wide:
extra_configs:
- CONFIG_UART_WIDE_DATA=y
tags: drivers uart
filter: CONFIG_UART_CONSOLE
harness: keyboard
arch_allow: arm
platform_allow: nucleo_h743zi
integration_platforms:
- nucleo_h743zi
extra_args: DTC_OVERLAY_FILE="boards/nucleo_h743zi.overlay"
drivers.uart.basic_api.poll:
extra_args: CONF_FILE=prj_poll.conf
tags:
- drivers
- uart
filter: CONFIG_UART_CONSOLE
harness: keyboard
integration_platforms:
- mps2/an385
drivers.uart.basic_api.shell:
extra_args: CONF_FILE=prj_shell.conf
min_flash: 64
tags:
- drivers
- uart
filter: CONFIG_UART_CONSOLE
harness: keyboard
integration_platforms:
- mps2/an385
drivers.uart.basic_api.cdc_acm:
extra_args:
- EXTRA_CONF_FILE="overlay-usb.conf"
- DTC_OVERLAY_FILE="usb.overlay"
tags:
- drivers
- usb
filter: CONFIG_UART_CONSOLE
depends_on: usb_device
harness: keyboard
drivers.uart.basic_api.shell_ke17z9_uart:
tags:
- drivers
- uart
filter: CONFIG_UART_CONSOLE
harness: keyboard
platform_allow: frdm_ke17z512
extra_args:
- CONF_FILE=prj_shell.conf
Expand Down
Loading