1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

tests/shell: fix test case for line cancelling

The test for the line cancellation (ctrl-c) functionality was unable to
detect error because of the way pexpect matches output.

While working on the long line shell bug, a regression was about to be
introduced because of this. This commit fixes the test by directly reading from
the child process and expects an exact response.

Co-authored-by: Juan Carrano <j.carrano@fu-berlin.de>
This commit is contained in:
Hendrik van Essen 2020-02-07 13:05:10 +01:00 committed by Francisco Molina
parent c1e3e613a5
commit 8a8416a6f6
No known key found for this signature in database
GPG Key ID: 3E94EAC3DBDEEDA8

View File

@ -52,7 +52,6 @@ CMDS = (
('help', EXPECTED_HELP),
('echo a string', ('\"echo\"\"a\"\"string\"')),
('ps', EXPECTED_PS),
('garbage1234'+CONTROL_C, ('>')), # test cancelling a line
('help', EXPECTED_HELP),
('reboot', ('test_shell.'))
)
@ -81,6 +80,15 @@ def check_and_get_bufsize(child):
return bufsize
def check_line_canceling(child):
child.expect(PROMPT)
child.sendline('garbage1234' + CONTROL_C)
garbage_expected = 'garbage1234\r\r\n'
garbage_received = child.read(len(garbage_expected))
assert garbage_expected == garbage_received
def testfunc(child):
# avoid sending an extra empty line on native.
if BOARD == 'native':
@ -90,6 +98,8 @@ def testfunc(child):
bufsize = check_and_get_bufsize(child)
check_line_canceling(child)
# loop other defined commands and expected output
for cmd, expected in CMDS:
check_cmd(child, cmd, expected)