Skip to content

Commit 5bd41f6

Browse files
alxelaxjgl-meta
authored andcommitted
tests: Bluetooth: Mesh: run bsim mesh tests from non-preemtible thread
BLE Mesh stack has been designed to work in non-preemtible environment. The PR fixes running bsim mesh test from main thread that is preemptible. Running mesh tests causes reentering in the same mesh functionality twice and rewriting ongoing data. Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
1 parent baeee77 commit 5bd41f6

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ bst_test_install_t test_installers[] = {
7474
NULL
7575
};
7676

77-
int main(void)
77+
static struct k_thread bsim_mesh_thread;
78+
static K_KERNEL_STACK_DEFINE(bsim_mesh_thread_stack, 4096);
79+
80+
static void bsim_mesh_entry_point(void *, void *, void *)
7881
{
7982
bst_main();
83+
}
84+
85+
int main(void)
86+
{
87+
k_thread_create(&bsim_mesh_thread, bsim_mesh_thread_stack,
88+
K_KERNEL_STACK_SIZEOF(bsim_mesh_thread_stack), bsim_mesh_entry_point, NULL,
89+
NULL, NULL, K_PRIO_COOP(1), 0, K_NO_WAIT);
90+
k_thread_name_set(&bsim_mesh_thread, "BabbleSim BLE Mesh tests");
91+
8092
return 0;
8193
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static void test_cli_broadcast_trans(void)
717717
FAIL("Broadcast did not trigger send CB");
718718
}
719719

720-
if (k_sem_take(&blob_broad_next_sem, K_NO_WAIT)) {
720+
if (k_sem_take(&blob_broad_next_sem, K_SECONDS(1))) {
721721
FAIL("Broadcast did not trigger next CB");
722722
}
723723

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,6 @@ static void test_lpn_msg_mesh(void)
477477
/* Receive an unsegmented message back */
478478
ASSERT_OK(bt_mesh_test_recv(5, cfg->addr, K_FOREVER));
479479

480-
/* Workaround while bug #57043 has not been fixed.
481-
* For details: https://github.com/zephyrproject-rtos/zephyr/issues/57043
482-
*/
483-
k_sleep(K_SECONDS(1));
484-
485480
/* Send a segmented message to the mesh node. */
486481
ASSERT_OK_MSG(bt_mesh_test_send(other_cfg.addr, 15, 0, K_FOREVER),
487482
"Send to other failed");

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,10 @@ static void test_tx_loopback(void)
179179
bt_mesh_test_setup();
180180

181181
for (int i = 0; i < ARRAY_SIZE(test_vector); i++) {
182-
bt_mesh_test_recv(test_vector[i].len, cfg->addr, K_NO_WAIT);
183-
err = bt_mesh_test_send(cfg->addr, test_vector[i].len,
184-
test_vector[i].flags,
185-
K_SECONDS(20));
182+
err = bt_mesh_test_send(cfg->addr, test_vector[i].len, test_vector[i].flags,
183+
K_NO_WAIT);
186184
ASSERT_OK_MSG(err, "Failed sending vector %d", i);
185+
bt_mesh_test_recv(test_vector[i].len, cfg->addr, K_SECONDS(1));
187186

188187
if (test_stats.received != i + 1) {
189188
FAIL("Didn't receive message %d", i);

0 commit comments

Comments
 (0)