tests: Bluetooth: Increase coverage for sync establishment

We didn't have test coverage for the scenario where the host
starts scanning automatically.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
Rubin Gerritsen 2024-04-29 15:16:47 +02:00 committed by Fabio Baltieri
commit 4095b790ee
2 changed files with 62 additions and 0 deletions

View file

@ -253,6 +253,33 @@ static void main_per_adv_syncer(void)
PASS("Periodic advertising syncer passed\n"); PASS("Periodic advertising syncer passed\n");
} }
static void main_per_adv_syncer_app_not_scanning(void)
{
int err;
struct bt_le_per_adv_sync *sync = NULL;
common_init();
start_scan();
printk("Waiting for periodic advertising...\n");
WAIT_FOR_FLAG(flag_per_adv);
printk("Found periodic advertising.\n");
printk("Stopping scan\n");
err = bt_le_scan_stop();
if (err != 0) {
FAIL("Failed to stop scan: %d", err);
return;
}
create_pa_sync(&sync);
printk("Waiting for periodic sync lost...\n");
WAIT_FOR_FLAG(flag_per_adv_sync_lost);
PASS("Periodic advertising syncer passed\n");
}
static void main_per_adv_conn_syncer(void) static void main_per_adv_conn_syncer(void)
{ {
struct bt_le_per_adv_sync *sync = NULL; struct bt_le_per_adv_sync *sync = NULL;
@ -341,6 +368,15 @@ static const struct bst_test_instance per_adv_syncer[] = {
.test_tick_f = test_tick, .test_tick_f = test_tick,
.test_main_f = main_per_adv_syncer .test_main_f = main_per_adv_syncer
}, },
{
.test_id = "per_adv_syncer_app_not_scanning",
.test_descr = "Basic periodic advertising sync test but where "
"the app stopped scanning before creating sync."
"Expect the host to start scanning automatically.",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = main_per_adv_syncer_app_not_scanning
},
{ {
.test_id = "per_adv_conn_syncer", .test_id = "per_adv_conn_syncer",
.test_descr = "Periodic advertising sync test, but where there " .test_descr = "Periodic advertising sync test, but where there "

View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# Periodic advertising sync test where the host starts scanning
# automatically because the application didn't start it.
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv_not_scanning"
verbosity_level=2
cd ${BSIM_OUT_PATH}/bin
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=0 \
-testid=per_adv_advertiser -rs=23
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \
-v=${verbosity_level} -s=${simulation_id} -d=1 -RealEncryption=0 \
-testid=per_adv_syncer_app_not_scanning -rs=6
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=20e6 $@
wait_for_background_jobs