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

tests/shell_ble: add variant of shell test for stdio_nimble

This commit is contained in:
Hendrik van Essen 2021-12-16 23:39:24 +01:00
parent 72a6ca6366
commit 7ab13448ef
7 changed files with 83 additions and 2 deletions

View File

@ -39,7 +39,13 @@ TEST_INTERACTIVE_DELAY = int(os.environ.get('TEST_INTERACTIVE_DELAY') or 1)
# By default never reset after the terminal is open unless explicitly requested
# through an environment variable.
TESTRUNNER_RESET_AFTER_TERM = int(os.environ.get('TESTRUNNER_RESET_AFTER_TERM')
or '0')
or 0)
# When running e.g. tests/shell_ble we don't want to reset the board, because
# then ble-serial would terminate and the created virtual serial port would get
# lost. By default the board is reset before the test starts.
TESTRUNNER_RESET_BOARD_ON_STARTUP = \
int(os.environ.get('TESTRUNNER_RESET_BOARD_ON_STARTUP') or 1)
MAKE = os.environ.get('MAKE', 'make')
@ -70,7 +76,8 @@ def find_exc_origin(exc_info):
def setup_child(timeout=10, spawnclass=pexpect.spawnu, env=None, logfile=None):
# Some boards can't be reset after a terminal is open. Therefore reset
# before `cleanterm`.
_reset_board(env)
if TESTRUNNER_RESET_BOARD_ON_STARTUP:
_reset_board(env)
# on platforms exposing UART over USB, wait a little before connecting to
# the serial terminal. This gives time for stdio to be ready.

View File

@ -50,6 +50,8 @@ USEMODULE += nimble_autoadv
USEMODULE += stdio_nimble
```
**NOTE:** You can also have a look at `tests/shell_ble`.
- Flash
`$ make -C tests/shell -j clean all flash`

View File

@ -32,6 +32,8 @@ EXPECTED_PS = (
RIOT_TERMINAL = os.environ.get('RIOT_TERMINAL')
CLEANTERMS = {"socat"}
TESTRUNNER_SHELL_SKIP_REBOOT = bool(int(os.environ.get('TESTRUNNER_SHELL_SKIP_REBOOT') or 0))
# In native we are directly executing the binary (no terminal program). We must
# therefore use Ctrl-V (DLE or "data link escape") before Ctrl-C to send a
# literal ETX instead of SIGINT.
@ -220,6 +222,10 @@ def testfunc(child):
# loop other defined commands and expected output
for cmd, expected in CMDS:
if cmd == "reboot" and TESTRUNNER_SHELL_SKIP_REBOOT:
continue
check_cmd(child, cmd, expected)
if RIOT_TERMINAL in CLEANTERMS:

42
tests/shell_ble/Makefile Normal file
View File

@ -0,0 +1,42 @@
DEVELHELP = 0
BOARD ?= nrf52dk
include ../Makefile.tests_common
USEMODULE += app_metadata
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ps
USEMODULE += stdio_nimble stdio_nimble_debug
USEMODULE += nimble_autoadv
CFLAGS += -DNIMBLE_AUTOADV_DEVICE_NAME='"tests/shell_ble"'
TESTRUNNER_SHELL_SKIP_REBOOT = 1
TESTRUNNER_RESET_BOARD_ON_STARTUP = 0
ifneq (,$(filter term,$(MAKECMDGOALS)))
# for z1, socat doesn't work (unknown reason)
ifeq (z1, $(BOARD))
RIOT_TERMINAL ?= pyterm
endif
# Use a terminal that does not introduce extra characters into the stream.
RIOT_TERMINAL ?= socat
else ifneq (,$(filter test,$(MAKECMDGOALS)))
# Use the virtual serial port created by ble-serial
RIOT_TERMINAL = picocom
endif
# The test requires some setup so it cannot currently be run
TEST_ON_CI_BLACKLIST += all
APP_SHELL_FMT ?= NONE
include $(RIOTBASE)/Makefile.include
# the test script skips tests if socat is not used
$(call target-export-variables,$(RIOT_TERMINAL),RIOT_TERMINAL)
# a reboot or a reset would disconnect the device from bluetooth and break the test
$(call target-export-variables,$(TESTRUNNER_SHELL_SKIP_REBOOT),TESTRUNNER_SHELL_SKIP_REBOOT)
$(call target-export-variables,$(TESTRUNNER_RESET_BOARD_ON_STARTUP),TESTRUNNER_RESET_BOARD_ON_STARTUP)

22
tests/shell_ble/README.md Normal file
View File

@ -0,0 +1,22 @@
This is basically the same tests as for the normal shell, but here we are
testing via blueooth instead of UART. You have to set up a virtual serial port
manually.
For instructions on how to open a virtual serial port to your bluetooth device
see `sys/stdio_nimble/README`.
**Note:** `make term` and `make test-with-config` will open two different types of terminals.
- When calling `make term` then a terminal will communicate with the board
via UART. Due to the nature of `stdio_nimble` the board won't respond to input
coming from here)
- When calling `make test-with-config` then picocom will communicate with the board via the
given virtual serial port
So a procedure to run this test could be:
0. Make sure that the current test application instance is fresh and no test was
run on it before. Otherwise your test might fail, because the test case
`check_control_d` only works once per run.
1. Execute `make flash term`
2. Open a virtual serial port with `ble-serial` and note the virtual serial port
that was created (search for `Slave created on /tmp/dev_riot_ble -> /dev/pts/25`)
3. Execute `PORT=/dev/pts/25 make test-with-config`

1
tests/shell_ble/main.c Symbolic link
View File

@ -0,0 +1 @@
../shell/main.c

View File

@ -0,0 +1 @@
../../shell/tests/01-run.py