tests: add interactive_sync adapted to shell
This commit is contained in:
parent
d57c39f09f
commit
a31003a23c
12
Makefile.dep
12
Makefile.dep
@ -1083,6 +1083,12 @@ ifneq (,$(filter ecc_%,$(USEMODULE)))
|
|||||||
USEMODULE += ecc
|
USEMODULE += ecc
|
||||||
endif
|
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
|
# recursively catch transitive dependencies
|
||||||
USEMODULE := $(sort $(USEMODULE))
|
USEMODULE := $(sort $(USEMODULE))
|
||||||
USEPKG := $(sort $(USEPKG))
|
USEPKG := $(sort $(USEPKG))
|
||||||
@ -1102,5 +1108,11 @@ else
|
|||||||
USEMODULE += $(filter periph_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
USEMODULE += $(filter periph_init_%,$(filter-out $(DISABLE_MODULE),$(DEFAULT_MODULE)))
|
||||||
endif
|
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))
|
USEMODULE := $(sort $(USEMODULE))
|
||||||
endif
|
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
|
# Do a child synchronization if used by a module
|
||||||
modules = modules_list()
|
modules = modules_list()
|
||||||
if 'test_utils_interactive_sync' in modules:
|
if 'test_utils_interactive_sync' in modules:
|
||||||
utils.test_utils_interactive_sync(child,
|
if 'test_utils_interactive_sync_shell' in modules:
|
||||||
TEST_INTERACTIVE_RETRIES,
|
utils.test_utils_interactive_sync_shell(child,
|
||||||
TEST_INTERACTIVE_DELAY)
|
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
|
# 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
|
# by any application since it breaks the tests for boards that do not support
|
||||||
# this feature.
|
# this feature.
|
||||||
|
|||||||
32
dist/pythonlibs/testrunner/utils.py
vendored
32
dist/pythonlibs/testrunner/utils.py
vendored
@ -9,19 +9,33 @@
|
|||||||
import pexpect
|
import pexpect
|
||||||
|
|
||||||
|
|
||||||
def test_utils_interactive_sync(child, retries, delay):
|
def _test_utils_interactive_sync(child, retries, delay, ready_cmd='r',
|
||||||
"""Synchronisation for 'test_utils_interactive_sync' function.
|
ready_exp='READY'):
|
||||||
|
|
||||||
Interacts through input to wait for node being ready.
|
for _ in range(retries):
|
||||||
"""
|
child.sendline(ready_cmd)
|
||||||
for _ in range(0, retries):
|
ret = child.expect_exact([ready_exp, pexpect.TIMEOUT], timeout=delay)
|
||||||
child.sendline('r')
|
|
||||||
ret = child.expect_exact(['READY', pexpect.TIMEOUT], timeout=delay)
|
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# Last call to make it fail her,
|
# Last call to make it fail here,
|
||||||
child.expect_exact('READY', timeout=0)
|
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.sendline('s')
|
||||||
child.expect_exact('START')
|
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)
|
# This pseudomodule causes a loop in AES to be unrolled (more flash, less CPU)
|
||||||
PSEUDOMODULES += crypto_aes_unroll
|
PSEUDOMODULES += crypto_aes_unroll
|
||||||
|
|
||||||
|
# declare shell version of test_utils_interactive_sync
|
||||||
|
PSEUDOMODULES += test_utils_interactive_sync_shell
|
||||||
|
|
||||||
# All auto_init modules are pseudomodules
|
# All auto_init modules are pseudomodules
|
||||||
PSEUDOMODULES += auto_init_%
|
PSEUDOMODULES += auto_init_%
|
||||||
NO_PSEUDOMODULES += auto_init_can
|
NO_PSEUDOMODULES += auto_init_can
|
||||||
|
|||||||
@ -238,8 +238,7 @@ void auto_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_USED(MODULE_TEST_UTILS_INTERACTIVE_SYNC) &&
|
if (IS_USED(MODULE_TEST_UTILS_INTERACTIVE_SYNC) && !IS_USED(MODULE_SHELL)) {
|
||||||
(!IS_USED(MODULE_SHELL_COMMANDS) || !IS_USED(MODULE_SHELL))) {
|
|
||||||
extern void test_utils_interactive_sync(void);
|
extern void test_utils_interactive_sync(void);
|
||||||
test_utils_interactive_sync();
|
test_utils_interactive_sync();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
application makefile `DISABLE_MODULE += test_utils_interactive_sync`. The python
|
||||||
test script will adapt to it automatically.
|
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
|
Running automated tests
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user