1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20962 from maribu/tests/sys/shell_lock/test-robustness

tests/sys/shell_lock: increase robustness of the test
This commit is contained in:
mguetschow 2024-11-07 12:21:04 +00:00 committed by GitHub
commit 76b9b711a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 17 deletions

View File

@ -20,6 +20,21 @@
#include "test_utils/interactive_sync.h"
/* this command is used by the test automation to check whether commands are
* executed or not (due to the shell being locked). */
static int _cmd_ping(int argc, char **argv)
{
if (argc != 1) {
printf("Usage: %s\n", argv[0]);
return 1;
}
puts("PONG!");
return 0;
}
SHELL_COMMAND(ping, "Echo \"PONG!\"", _cmd_ping);
int main(void)
{
test_utils_interactive_sync();

View File

@ -22,15 +22,6 @@ PASSWORDS_INCORRECT = [
"_password"
]
EXPECTED_HELP = (
'Command Description',
'---------------------------------------',
'lock Lock the shell',
'pm interact with layered PM subsystem',
'reboot Reboot the node',
'version Prints current RIOT_VERSION',
)
AUTO_LOCK_TIMEOUT_MS = 7000
SHELL_PROMPT = '> '
PASSWORD_PROMPT = 'Password: '
@ -49,16 +40,15 @@ def testfunc(child):
child.expect_exact(SHELL_PROMPT)
# check we have access
child.sendline('help')
for line in EXPECTED_HELP:
child.expect_exact(line)
child.sendline('ping')
child.expect_exact("PONG!")
# lock
child.sendline('lock')
child.expect(SHELL_PROMPT)
# trigger password prompt
child.sendline('help')
child.sendline('ping')
child.expect('The shell is locked. Enter a valid password to unlock.')
# test different incorrect passwords
@ -82,16 +72,15 @@ def testfunc(child):
child.expect_exact(SHELL_PROMPT)
# check we have access
child.sendline('help')
for line in EXPECTED_HELP:
child.expect_exact(line)
child.sendline('ping')
child.expect_exact("PONG!")
# wait until auto_lock locks the shell after
# CONFIG_SHELL_LOCK_AUTO_LOCK_TIMEOUT_MS (+ 1 second buffer time)
time.sleep((AUTO_LOCK_TIMEOUT_MS / 1000.0) + 1)
# trigger password prompt
child.sendline('help')
child.sendline('ping')
child.expect('The shell is locked. Enter a valid password to unlock.')