Skip to content

Commit 2ca438f

Browse files
aescolarcarlescufi
authored andcommitted
tests/bluetooth/mesh: Synchronize devices before boot
To ensure no indeterminism, synchronize devices before they boot, and therefore before the test main function is executed. Note that at this point, there is no actual indeterminism to correct. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 9250749 commit 2ca438f

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

tests/bluetooth/bsim/mesh/_mesh_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function RunTest(){
7575

7676
Execute \
7777
${exe_name} \
78-
-v=${verbosity_level} -s=$s_id -d=$idx -RealEncryption=1 \
78+
-v=${verbosity_level} -s=$s_id -d=$idx -sync_preboot -RealEncryption=1 \
7979
-testid=$testid ${test_options}
8080
let idx=idx+1
8181
done

tests/bluetooth/bsim/mesh/src/test_provision.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,8 @@ static void oob_auth_set(int test_step)
327327

328328
static void oob_device(bool use_oob_pk)
329329
{
330-
int err = 0;
331-
332330
k_sem_init(&prov_sem, 0, 1);
333331

334-
oob_channel_id = bs_open_back_channel(get_device_nbr(),
335-
(uint[]){(get_device_nbr() + 1) % 2}, (uint[]){0}, 1);
336-
if (!oob_channel_id) {
337-
FAIL("Can't open OOB interface (err %d)\n", err);
338-
}
339-
340332
bt_mesh_device_setup(&prov, &comp);
341333

342334
if (use_oob_pk) {
@@ -366,16 +358,8 @@ static void oob_device(bool use_oob_pk)
366358

367359
static void oob_provisioner(bool read_oob_pk, bool use_oob_pk)
368360
{
369-
int err = 0;
370-
371361
k_sem_init(&prov_sem, 0, 1);
372362

373-
oob_channel_id = bs_open_back_channel(get_device_nbr(),
374-
(uint[]){(get_device_nbr() + 1) % 2}, (uint[]){0}, 1);
375-
if (!oob_channel_id) {
376-
FAIL("Can't open OOB interface (err %d)\n", err);
377-
}
378-
379363
bt_mesh_device_setup(&prov, &comp);
380364

381365
if (read_oob_pk) {
@@ -549,6 +533,15 @@ static void test_provisioner_pb_adv_oob_auth(void)
549533
PASS();
550534
}
551535

536+
static void test_back_channel_pre_init(void)
537+
{
538+
oob_channel_id = bs_open_back_channel(get_device_nbr(),
539+
(uint[]){(get_device_nbr() + 1) % 2}, (uint[]){0}, 1);
540+
if (!oob_channel_id) {
541+
FAIL("Can't open OOB interface\n");
542+
}
543+
}
544+
552545
static void test_device_pb_adv_oob_public_key(void)
553546
{
554547
oob_device(true);
@@ -1196,13 +1189,22 @@ static void test_device_pb_remote_server_ncrp_second_time(void)
11961189
.test_main_f = test_##role##_##name, \
11971190
.test_delete_f = test_terminate \
11981191
}
1192+
#define TEST_CASE_WBACKCHANNEL(role, name, description) \
1193+
{ \
1194+
.test_id = "prov_" #role "_" #name, .test_descr = description, \
1195+
.test_post_init_f = test_##role##_init, \
1196+
.test_pre_init_f = test_back_channel_pre_init, \
1197+
.test_tick_f = bt_mesh_test_timeout, \
1198+
.test_main_f = test_##role##_##name, \
1199+
.test_delete_f = test_terminate \
1200+
}
11991201

12001202
static const struct bst_test_instance test_connect[] = {
12011203
TEST_CASE(device, pb_adv_no_oob,
12021204
"Device: pb-adv provisioning use no-oob method"),
1203-
TEST_CASE(device, pb_adv_oob_auth,
1205+
TEST_CASE_WBACKCHANNEL(device, pb_adv_oob_auth,
12041206
"Device: pb-adv provisioning use oob authentication"),
1205-
TEST_CASE(device, pb_adv_oob_public_key,
1207+
TEST_CASE_WBACKCHANNEL(device, pb_adv_oob_public_key,
12061208
"Device: pb-adv provisioning use oob public key"),
12071209
TEST_CASE(device, pb_adv_reprovision,
12081210
"Device: pb-adv provisioning, reprovision"),
@@ -1221,11 +1223,11 @@ static const struct bst_test_instance test_connect[] = {
12211223
"Provisioner: effect on ivu_duration when IV Update flag is set to zero"),
12221224
TEST_CASE(provisioner, iv_update_flag_one,
12231225
"Provisioner: effect on ivu_duration when IV Update flag is set to one"),
1224-
TEST_CASE(provisioner, pb_adv_oob_auth,
1226+
TEST_CASE_WBACKCHANNEL(provisioner, pb_adv_oob_auth,
12251227
"Provisioner: pb-adv provisioning use oob authentication"),
1226-
TEST_CASE(provisioner, pb_adv_oob_public_key,
1228+
TEST_CASE_WBACKCHANNEL(provisioner, pb_adv_oob_public_key,
12271229
"Provisioner: pb-adv provisioning use oob public key"),
1228-
TEST_CASE(provisioner, pb_adv_oob_auth_no_oob_public_key,
1230+
TEST_CASE_WBACKCHANNEL(provisioner, pb_adv_oob_auth_no_oob_public_key,
12291231
"Provisioner: pb-adv provisioning use oob authentication, ignore oob public key"),
12301232
TEST_CASE(provisioner, pb_adv_reprovision,
12311233
"Provisioner: pb-adv provisioning, resetting and reprovisioning multiple times."),

0 commit comments

Comments
 (0)