mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
Merge pull request #13613 from fjmolinas/pr_light_shell_interactive_sync
tests: add interactive_sync adapted to shell
This commit is contained in:
commit
6538687a4c
12
Makefile.dep
12
Makefile.dep
@ -1078,6 +1078,12 @@ ifneq (,$(filter ecc_%,$(USEMODULE)))
|
||||
USEMODULE += ecc
|
||||
endif
|
||||
|
||||
ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE)))
|
||||
ifneq (,$(filter shell,$(USEMODULE)))
|
||||
DEFAULT_MODULE += test_utils_interactive_sync_shell
|
||||
endif
|
||||
endif
|
||||
|
||||
# recursively catch transitive dependencies
|
||||
USEMODULE := $(sort $(USEMODULE))
|
||||
USEPKG := $(sort $(USEPKG))
|
||||
@ -1102,5 +1108,11 @@ else
|
||||
USEMODULE += $(filter periph_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
||||
endif
|
||||
|
||||
# Add test_utils_interactive_sync_shell
|
||||
ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE)))
|
||||
USEMODULE += $(filter test_utils_interactive_sync_%, \
|
||||
$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
||||
endif
|
||||
|
||||
USEMODULE := $(sort $(USEMODULE))
|
||||
endif
|
||||
|
11
dist/pythonlibs/testrunner/spawn.py
vendored
11
dist/pythonlibs/testrunner/spawn.py
vendored
@ -99,9 +99,14 @@ def sync_child(child, env):
|
||||
# Do a child synchronization if used by a module
|
||||
modules = modules_list()
|
||||
if 'test_utils_interactive_sync' in modules:
|
||||
utils.test_utils_interactive_sync(child,
|
||||
TEST_INTERACTIVE_RETRIES,
|
||||
TEST_INTERACTIVE_DELAY)
|
||||
if 'test_utils_interactive_sync_shell' in modules:
|
||||
utils.test_utils_interactive_sync_shell(child,
|
||||
TEST_INTERACTIVE_RETRIES,
|
||||
TEST_INTERACTIVE_DELAY)
|
||||
else:
|
||||
utils.test_utils_interactive_sync(child,
|
||||
TEST_INTERACTIVE_RETRIES,
|
||||
TEST_INTERACTIVE_DELAY)
|
||||
# If requested also reset after opening the terminal, this should not be used
|
||||
# by any application since it breaks the tests for boards that do not support
|
||||
# this feature.
|
||||
|
32
dist/pythonlibs/testrunner/utils.py
vendored
32
dist/pythonlibs/testrunner/utils.py
vendored
@ -9,19 +9,33 @@
|
||||
import pexpect
|
||||
|
||||
|
||||
def test_utils_interactive_sync(child, retries, delay):
|
||||
"""Synchronisation for 'test_utils_interactive_sync' function.
|
||||
def _test_utils_interactive_sync(child, retries, delay, ready_cmd='r',
|
||||
ready_exp='READY'):
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
for _ in range(0, retries):
|
||||
child.sendline('r')
|
||||
ret = child.expect_exact(['READY', pexpect.TIMEOUT], timeout=delay)
|
||||
for _ in range(retries):
|
||||
child.sendline(ready_cmd)
|
||||
ret = child.expect_exact([ready_exp, pexpect.TIMEOUT], timeout=delay)
|
||||
if ret == 0:
|
||||
break
|
||||
else:
|
||||
# Last call to make it fail her,
|
||||
child.expect_exact('READY', timeout=0)
|
||||
# Last call to make it fail here,
|
||||
child.expect_exact(ready_exp, timeout=0)
|
||||
|
||||
|
||||
def test_utils_interactive_sync(child, retries, delay):
|
||||
"""Synchronization for 'test_utils_interactive_sync' function
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
_test_utils_interactive_sync(child, retries, delay)
|
||||
child.sendline('s')
|
||||
child.expect_exact('START')
|
||||
|
||||
|
||||
def test_utils_interactive_sync_shell(child, retries, delay):
|
||||
"""Synchronization `shell` and `test_utils_interactive_sync` modules are
|
||||
used ('test_utils_interactive_sync' function is not)
|
||||
|
||||
Interacts through input to wait for node being ready.
|
||||
"""
|
||||
_test_utils_interactive_sync(child, retries, delay, '\n', '>')
|
||||
|
@ -227,6 +227,9 @@ PSEUDOMODULES += crypto_aes_precalculated
|
||||
# This pseudomodule causes a loop in AES to be unrolled (more flash, less CPU)
|
||||
PSEUDOMODULES += crypto_aes_unroll
|
||||
|
||||
# declare shell version of test_utils_interactive_sync
|
||||
PSEUDOMODULES += test_utils_interactive_sync_shell
|
||||
|
||||
# All auto_init modules are pseudomodules
|
||||
PSEUDOMODULES += auto_init_%
|
||||
NO_PSEUDOMODULES += auto_init_can
|
||||
|
@ -238,8 +238,7 @@ void auto_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_TEST_UTILS_INTERACTIVE_SYNC) &&
|
||||
(!IS_USED(MODULE_SHELL_COMMANDS) || !IS_USED(MODULE_SHELL))) {
|
||||
if (IS_USED(MODULE_TEST_UTILS_INTERACTIVE_SYNC) && !IS_USED(MODULE_SHELL)) {
|
||||
extern void test_utils_interactive_sync(void);
|
||||
test_utils_interactive_sync();
|
||||
}
|
||||
|
@ -96,10 +96,6 @@ ifneq (,$(filter nimble_netif,$(USEMODULE)))
|
||||
SRC += sc_nimble_netif.c
|
||||
endif
|
||||
|
||||
ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE)))
|
||||
SRC += sc_interactive_sync.c
|
||||
endif
|
||||
|
||||
ifneq (,$(filter suit_coap,$(USEMODULE)))
|
||||
SRC += sc_suit.c
|
||||
endif
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup sys_shell_commands
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Shell commands interactive sync util
|
||||
*
|
||||
* @author Francisco Molina <francois-xavier.molina@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "test_utils/interactive_sync.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include <avr/pgmspace.h>
|
||||
/* For small AVR targets the extra strings generated by test interactive
|
||||
can make the application overflow the .data section (RAM), we use puts_P()
|
||||
to write those constant string to .txt section (FLASH)*/
|
||||
#define PUTS(_s) puts_P(PSTR(_s))
|
||||
#else
|
||||
#define PUTS(_s) puts(_s)
|
||||
#endif
|
||||
|
||||
int _test_start(int argc, char **argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
PUTS("START");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int _test_ready(int argc, char **argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
PUTS("READY");
|
||||
return 0;
|
||||
}
|
@ -159,11 +159,6 @@ extern int _loramac_handler(int argc, char **argv);
|
||||
extern int _nimble_netif_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_TEST_UTILS_INTERACTIVE_SYNC
|
||||
extern int _test_start(int argc, char **argv);
|
||||
extern int _test_ready(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_SUIT_COAP
|
||||
extern int _suit_handler(int argc, char **argv);
|
||||
#endif
|
||||
@ -275,10 +270,6 @@ const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_NIMBLE_NETIF
|
||||
{ "ble", "Manage BLE connections for NimBLE", _nimble_netif_handler },
|
||||
#endif
|
||||
#ifdef MODULE_TEST_UTILS_INTERACTIVE_SYNC
|
||||
{ "r", "Test sync, Ready query", _test_ready },
|
||||
{ "s", "Test sync, Start test trigger", _test_start },
|
||||
#endif
|
||||
#ifdef MODULE_SUIT_COAP
|
||||
{ "suit", "Trigger a SUIT firmware update", _suit_handler },
|
||||
#endif
|
||||
|
@ -26,6 +26,14 @@ default module in `Makefile.tests_common`. It can be disabled by setting in the
|
||||
application makefile `DISABLE_MODULE += test_utils_interactive_sync`. The python
|
||||
test script will adapt to it automatically.
|
||||
|
||||
When using the `shell` module, `test_utils_interactive_sync` will use the shell
|
||||
itself to synchronize, and will not use `test_utils_interactive_sync();` function
|
||||
to synchronize. Some times you will want to synchronize before the start of the
|
||||
script and use `test_utils_interactive_sync();` function (e.g.:
|
||||
[tests/ps_schedstatistics](tests/ps_schedstatistics/main.c)). For these cases
|
||||
you can disable `test_utils_interactive_sync_shell` module in the application
|
||||
`Makefile`: `DISABLE_MODULE += test_utils_interactive_sync_shell`.
|
||||
|
||||
|
||||
Running automated tests
|
||||
-----------------------
|
||||
|
@ -15,9 +15,6 @@ TIMEOUT = 30
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact("GPIO peripheral driver test")
|
||||
child.expect_exact(">")
|
||||
|
||||
for pin in range(0, 8):
|
||||
child.sendline("bench 0 {}".format(pin))
|
||||
child.expect(r" *nop loop: +(\d+)us --- +(\d+\.\d+)us per call --- +(\d+) calls per sec")
|
||||
|
@ -5,6 +5,5 @@ FEATURES_REQUIRED += periph_wdt
|
||||
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -6,4 +6,9 @@ USEMODULE += ps
|
||||
USEMODULE += schedstatistics
|
||||
USEMODULE += printf_float
|
||||
|
||||
# For this test we don't want to use the shell version of
|
||||
# test_utils_interactive_sync, since we want to synchronize before
|
||||
# the start of the shell
|
||||
DISABLE_MODULE += test_utils_interactive_sync_shell
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -1,7 +1,6 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += timex
|
||||
|
||||
# The MSP-430 toolchain lacks sscanf:
|
||||
|
@ -6,4 +6,8 @@ USEMODULE += shell
|
||||
# Disable shell echo and prompt to not have them in the way for testing
|
||||
CFLAGS += -DSHELL_NO_ECHO=1 -DSHELL_NO_PROMPT=1
|
||||
|
||||
# No need for test_utils_interactive_sync in this test since the test
|
||||
# synchronizes by itself through `shellping` command.
|
||||
DISABLE_MODULE += test_utils_interactive_sync
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -64,8 +64,6 @@ def testfunc(child):
|
||||
* getting some test output without other messages
|
||||
* sending empty lines
|
||||
"""
|
||||
child.expect_exact("Running 'tests_tools' application")
|
||||
|
||||
_wait_shell_ready(child)
|
||||
|
||||
# Verify there is no local and remote echo as it is disabled
|
||||
|
Loading…
Reference in New Issue
Block a user