Skip to content

Commit

Permalink
tests/shell: add test case for line editing
Browse files Browse the repository at this point in the history
Test erasing characters using backspace. The test is not really testing
a lot right now, because the host is still line buffering.

Co-authored-by: Juan Carrano <[email protected]>
  • Loading branch information
HendrikVE and jcarrano committed Feb 9, 2020
1 parent 76a97ec commit a3c1fca
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/shell/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
'shell: command not found: '
'123456789012345678901234567890123456789012345678901234567890'),
('unknown_command', 'shell: command not found: unknown_command'),
('hello-willy\b\b\b\borld', 'shell: command not found: hello-world'),
('\b\b\b\becho', '\"echo\"'),
('help', EXPECTED_HELP),
('echo a string', '\"echo\"\"a\"\"string\"'),
('ps', EXPECTED_PS),
Expand Down Expand Up @@ -87,16 +89,14 @@ def check_and_get_bufsize(child):
return bufsize


def check_line_exceeded(child, bufsize):
def check_line_exceeded(child, longline):

if BOARD == 'nrf52dk':
# looks like the nrf52dk runs in to undefined behaviour when sending more
# than 64 bytes over UART
print_error('test case "check_line_exceeded" broken for nrf52dk. SKIP')
return

longline = "_"*bufsize + "verylong"

child.sendline(longline)
child.expect('shell: maximum line length exceeded')

Expand All @@ -110,6 +110,16 @@ def check_line_canceling(child):
assert garbage_expected == garbage_received


def check_erase_long_line(child, longline):
# FIXME: this only works on native, due to #10634 combined with socat
# insisting in line-buffering the terminal.

if BOARD == 'native':
longline_erased = longline + "\b"*len(longline) + "echo"
child.sendline(longline_erased)
child.expect_exact('"echo"')


def testfunc(child):
# avoid sending an extra empty line on native.
if BOARD == 'native':
Expand All @@ -118,11 +128,14 @@ def testfunc(child):
check_startup(child)

bufsize = check_and_get_bufsize(child)
longline = "_"*bufsize + "verylong"

check_line_exceeded(child, bufsize)
check_line_exceeded(child, longline)

check_line_canceling(child)

check_erase_long_line(child, longline)

# loop other defined commands and expected output
for cmd, expected in CMDS:
check_cmd(child, cmd, expected)
Expand Down

0 comments on commit a3c1fca

Please sign in to comment.