1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 22:43:50 +01:00

tests/test_tools: test receiving an empty line

Test receiving an empty line.
It was before not possible with `pyterm` but is fixed by previous
commit.
This commit is contained in:
Gaëtan Harter 2019-08-27 15:09:49 +02:00
parent baad72c44a
commit 1fce298441
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B
2 changed files with 34 additions and 1 deletions

View File

@ -66,7 +66,6 @@ static int cmd_shellping(int argc, char **argv)
return 0;
}
/**
* @brief Uppercase the first word
*
@ -98,11 +97,31 @@ static int cmd_toupper(int argc, char **argv)
return 0;
}
/**
* @brief getchar, read one character
*
* Read one character and print its hex value
*
* @param[in] argc Number of arguments
* @param[in] argv Array of arguments
*
* @return 0
*
*/
static int cmd_getchar(int argc, char **argv)
{
(void)argc;
(void)argv;
printf("%s 0x%02x\n", argv[0], getchar());
return 0;
}
static const shell_command_t shell_commands[] = {
{ "shellping", "Just print 'shellpong'", cmd_shellping },
{ "true", "do nothing, successfully", cmd_true },
{ "toupper", "uppercase first argument", cmd_toupper },
{ "getchar", "Get one character and print the hex value", cmd_getchar },
{ NULL, NULL, NULL }
};

View File

@ -38,6 +38,16 @@ def _test_no_local_echo(child):
assert res == 0, "There should have been a timeout and not match stdin"
def _test_sending_newline(child):
"""Verify that a empty line can be send to the node.
The local terminal must NOT repeat the previous command.
"""
child.sendline('getchar')
child.sendline('') # send only one newline character
child.expect_exact('getchar 0x0a\r\n')
def _test_clean_output(child):
"""Verify that only what the node sends is received."""
child.sendline('toupper lowercase')
@ -52,6 +62,7 @@ def testfunc(child):
* local echo
* getting some test output without other messages
* sending empty lines
"""
child.expect_exact("Running 'tests_tools' application")
@ -66,6 +77,9 @@ def testfunc(child):
# Check that the output is clean without extra terminal output
_test_clean_output(child)
# It is possible to send an empty newline
_test_sending_newline(child)
if __name__ == "__main__":
sys.exit(run(testfunc))