tests bsim/net: Add simple echo test over OpenThread

Expand the tests/bsim/net/sockets/echo_test
with a variant using OpenThread

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-03-21 12:20:12 +01:00 committed by Carles Cufí
commit b6c6de386c
5 changed files with 86 additions and 0 deletions

View file

@ -23,4 +23,7 @@ source ${ZEPHYR_BASE}/tests/bsim/compile.source
app=samples/net/sockets/echo_server conf_overlay=overlay-802154.conf compile
app=tests/bsim/net/sockets/echo_test conf_overlay=overlay-802154.conf compile
app=samples/net/sockets/echo_server conf_overlay=overlay-ot.conf compile
app=tests/bsim/net/sockets/echo_test conf_overlay=overlay-ot.conf compile
wait_for_background_jobs

View file

@ -0,0 +1,4 @@
# The nrf52 HW models do not have a flash model yet. Even though it is possible to use different
# replacements, the easiest one is to disable the flash, so when configured with openthread
# it will use the OPENTHREAD_SETTINGS_RAM
CONFIG_FLASH=n

View file

@ -0,0 +1,43 @@
# This file content is just a copy of the echo client overlay-ot.conf
CONFIG_NEWLIB_LIBC=y
# Disable TCP and IPv4 (TCP disabled to avoid heavy traffic)
CONFIG_NET_TCP=n
CONFIG_NET_IPV4=n
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n
CONFIG_NET_CONFIG_NEED_IPV4=n
CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2560
# Enable OpenThread shell
CONFIG_SHELL=y
CONFIG_OPENTHREAD_SHELL=y
CONFIG_SHELL_STACK_SIZE=3072
CONFIG_NET_L2_OPENTHREAD=y
CONFIG_OPENTHREAD_DEBUG=y
CONFIG_OPENTHREAD_L2_DEBUG=y
CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y
CONFIG_OPENTHREAD_CHANNEL=26
CONFIG_OPENTHREAD_NETWORKKEY="00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff"
CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2"
# mbedTLS tweaks
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=768
# A sample configuration to enable Thread Joiner, uncomment if needed
#CONFIG_OPENTHREAD_JOINER=y
#CONFIG_OPENTHREAD_JOINER_AUTOSTART=y
# Enable diagnostic module, uncomment if needed
#CONFIG_OPENTHREAD_DIAG=y

View file

@ -12,7 +12,13 @@
#include "common.h" /* From echo_client */
#if defined(CONFIG_NET_L2_OPENTHREAD)
/* Open thread takes ~15 seconds to connect in ideal conditions */
#define WAIT_TIME 25 /* Seconds */
#else
#define WAIT_TIME 20 /* Seconds */
#endif
#define PASS_THRESHOLD 100 /* Packets */
extern enum bst_result_t bst_result;

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Copyright 2018 Oticon A/S
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# Simple selfchecking test for openthread, based on the echo client / server sample apps
# It relies on the bs_tests hooks to register a test timer callback, which after a deadline
# will check how many packets the echo client has got back as expected, and if over a threshold
# it considers the test passed
simulation_id="echo_test_ot"
verbosity_level=2
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
EXECUTE_TIMEOUT=100
cd ${BSIM_OUT_PATH}/bin
Execute ./bs_${BOARD}_tests_bsim_net_sockets_echo_test_prj_conf_overlay-ot_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=1 \
-testid=echo_client
Execute ./bs_${BOARD}_samples_net_sockets_echo_server_prj_conf_overlay-ot_conf\
-v=${verbosity_level} -s=${simulation_id} -d=1 -RealEncryption=1 \
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=60e6 -argschannel -at=40 $@
wait_for_background_jobs #Wait for all programs in background and return != 0 if any fails