Bluetooth: Host: Add test for autoconnection of EATT channels
Checks that CONFIG_BT_EATT_MAX EATT channels are created automatically after connection. Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This commit is contained in:
parent
bc6501b611
commit
db3a6e17fa
6 changed files with 117 additions and 1 deletions
|
@ -16,6 +16,7 @@ project(bsim_test_host)
|
|||
target_sources(app PRIVATE
|
||||
src/common.c
|
||||
src/main_collision.c
|
||||
src/main_autoconnect.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
|
|
14
tests/bluetooth/bsim_bt/bsim_test_eatt/prj_autoconnect.conf
Normal file
14
tests/bluetooth/bsim_bt/bsim_test_eatt/prj_autoconnect.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
CONFIG_BT=y
|
||||
CONFIG_BT_CENTRAL=y
|
||||
CONFIG_BT_PERIPHERAL=y
|
||||
CONFIG_BT_SMP=y
|
||||
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_BT_DEVICE_NAME="EATT test"
|
||||
CONFIG_BT_EATT=y
|
||||
CONFIG_BT_L2CAP_ECRED=y
|
||||
CONFIG_BT_EATT_MAX=5
|
||||
CONFIG_BT_MAX_CONN=1
|
||||
|
||||
CONFIG_BT_TESTING=y
|
||||
CONFIG_BT_DEBUG_LOG=y
|
||||
CONFIG_ASSERT=y
|
|
@ -7,10 +7,12 @@
|
|||
#include "bstests.h"
|
||||
|
||||
extern struct bst_test_list *test_main_collision_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_main_autoconnect_install(struct bst_test_list *tests);
|
||||
|
||||
bst_test_install_t test_installers[] = {
|
||||
test_main_collision_install,
|
||||
NULL
|
||||
test_main_autoconnect_install,
|
||||
NULL,
|
||||
};
|
||||
|
||||
void main(void)
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/* main_connect.c - Application main entry point */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Nordic Semiconductor
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static void test_peripheral_main(void)
|
||||
{
|
||||
peripheral_setup_and_connect();
|
||||
|
||||
while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
|
||||
k_sleep(K_MSEC(10));
|
||||
}
|
||||
|
||||
/* Do not disconnect until the central also has connected all channels */
|
||||
k_sleep(K_MSEC(1000));
|
||||
|
||||
disconnect();
|
||||
|
||||
PASS("EATT Peripheral tests Passed\n");
|
||||
}
|
||||
|
||||
static void test_central_main(void)
|
||||
{
|
||||
central_setup_and_connect();
|
||||
|
||||
while (bt_eatt_count(default_conn) < CONFIG_BT_EATT_MAX) {
|
||||
k_sleep(K_MSEC(10));
|
||||
}
|
||||
|
||||
wait_for_disconnect();
|
||||
|
||||
PASS("EATT Central tests Passed\n");
|
||||
}
|
||||
|
||||
static const struct bst_test_instance test_def[] = {
|
||||
{
|
||||
.test_id = "peripheral_autoconnect",
|
||||
.test_descr = "Peripheral autoconnect",
|
||||
.test_post_init_f = test_init,
|
||||
.test_tick_f = test_tick,
|
||||
.test_main_f = test_peripheral_main,
|
||||
},
|
||||
{
|
||||
.test_id = "central_autoconnect",
|
||||
.test_descr = "Central autoconnect",
|
||||
.test_post_init_f = test_init,
|
||||
.test_tick_f = test_tick,
|
||||
.test_main_f = test_central_main,
|
||||
},
|
||||
BSTEST_END_MARKER,
|
||||
};
|
||||
|
||||
struct bst_test_list *test_main_autoconnect_install(struct bst_test_list *tests)
|
||||
{
|
||||
return bst_add_tests(tests, test_def);
|
||||
}
|
37
tests/bluetooth/bsim_bt/bsim_test_eatt/tests_scripts/autoconnect.sh
Executable file
37
tests/bluetooth/bsim_bt/bsim_test_eatt/tests_scripts/autoconnect.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2022 Nordic Semiconductor
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
simulation_id="connection"
|
||||
verbosity_level=2
|
||||
process_ids=""; exit_code=0
|
||||
|
||||
function Execute(){
|
||||
if [ ! -f $1 ]; then
|
||||
echo -e " \e[91m`pwd`/`basename $1` cannot be found (did you forget to\
|
||||
compile it?)\e[39m"
|
||||
exit 1
|
||||
fi
|
||||
timeout 120 $@ & process_ids="$process_ids $!"
|
||||
}
|
||||
|
||||
: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}"
|
||||
|
||||
#Give a default value to BOARD if it does not have one yet:
|
||||
BOARD="${BOARD:-nrf52_bsim}"
|
||||
|
||||
cd ${BSIM_OUT_PATH}/bin
|
||||
|
||||
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_eatt_prj_autoconnect_conf \
|
||||
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central_autoconnect
|
||||
|
||||
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_eatt_prj_autoconnect_conf \
|
||||
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral_autoconnect
|
||||
|
||||
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
|
||||
-D=2 -sim_length=200e6 $@
|
||||
|
||||
for process_id in $process_ids; do
|
||||
wait $process_id || let "exit_code=$?"
|
||||
done
|
||||
exit $exit_code #the last exit code != 0
|
|
@ -23,6 +23,7 @@ source ${ZEPHYR_BASE}/tests/bluetooth/bsim_bt/compile.source
|
|||
app=tests/bluetooth/bsim_bt/bsim_test_eatt conf_file=prj_encryption.conf compile
|
||||
app=tests/bluetooth/bsim_bt/bsim_test_eatt conf_file=prj_collision.conf compile
|
||||
app=tests/bluetooth/bsim_bt/bsim_test_eatt conf_file=prj_multiple_conn.conf compile
|
||||
app=tests/bluetooth/bsim_bt/bsim_test_eatt conf_file=prj_autoconnect.conf compile
|
||||
app=tests/bluetooth/bsim_bt/bsim_test_app conf_file=prj_split.conf \
|
||||
compile
|
||||
app=tests/bluetooth/bsim_bt/bsim_test_app conf_file=prj_split_privacy.conf \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue