Skip to content

Commit

Permalink
tests/shell: Test exit with control-D.
Browse files Browse the repository at this point in the history
Test that the shell exits on ctrl-D and that it exits only once.
  • Loading branch information
jcarrano committed Sep 10, 2019
1 parent eba6c54 commit f56eb5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/shell/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ int main(void)
/* define own shell commands */
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

puts("shell exited (1)");

/* Restart the shell after the previous one exits, so that we can test
* ctrl-D exit */
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);

puts("shell exited (2)");

/* or use only system shell commands */
/*
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
Expand Down
2 changes: 2 additions & 0 deletions tests/shell/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
('help', EXPECTED_HELP),
('echo a string', ('\"echo\"\"a\"\"string\"')),
('ps', EXPECTED_PS),
('reboot', ('test_shell.')),
(CONTROL_D, ('shell exited (1)')),
('garbage1234'+CONTROL_C, ('>')), # test cancelling a line
('help', EXPECTED_HELP),
('reboot', ('test_shell.'))
Expand Down

0 comments on commit f56eb5b

Please sign in to comment.