File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
samples/subsys/console/getline Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (c) 2023 Nordic Semiconductor ASA
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ import logging
6+ import pytest
7+ from twister_harness import DeviceAdapter
8+ import re
9+
10+ logger = logging .getLogger (__name__ )
11+
12+ TESTDATA = [
13+ ('Zephyr is great' , 'line: Zephyr is great' ),
14+ ('This is a test' , 'line: This is a test' ),
15+ ]
16+ @pytest .mark .parametrize ('command,expected' , TESTDATA )
17+ def test_getline (dut : DeviceAdapter , command , expected ):
18+ command_ext = f'{ command } \n \n '
19+ regex_expected = f'.*{ re .escape (expected )} '
20+ dut .clear_buffer ()
21+ dut .write (command_ext .encode ())
22+ lines : list [str ] = []
23+ lines .extend (dut .readlines_until (regex = regex_expected , timeout = 10.0 , print_output = True ))
24+ assert expected in lines , 'expected response not found'
Original file line number Diff line number Diff line change 66 - mps2/an385
77 filter : CONFIG_UART_CONSOLE and CONFIG_SERIAL_SUPPORT_INTERRUPT
88 tags : console
9- harness : keyboard
9+ harness : pytest
You can’t perform that action at this time.
0 commit comments