diff --git a/tests/test_tools/main.c b/tests/test_tools/main.c index c7fdbcd61f..1051930c1b 100644 --- a/tests/test_tools/main.c +++ b/tests/test_tools/main.c @@ -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 } }; diff --git a/tests/test_tools/tests/01-run.py b/tests/test_tools/tests/01-run.py index 1b2dbec982..ca278074a8 100755 --- a/tests/test_tools/tests/01-run.py +++ b/tests/test_tools/tests/01-run.py @@ -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))