Bluetooth: Mesh: Bsim test for LPN terminate cb

Test covering a corner case scenario where the LPN has received a
friend offer, but has not yet established a connection. In this case
the LPN terminate callback should not be triggered if the LPN is
disabled, which is monitored by this test.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This commit is contained in:
Anders Storrø 2022-01-17 14:06:56 +01:00 committed by Anas Nashif
commit 54271d23e8
2 changed files with 43 additions and 5 deletions

View file

@ -850,10 +850,32 @@ static void test_lpn_disable(void)
PASS();
}
/** LPN terminate cb test.
*
* Check that terminate cb is not triggered when there is no established
* connection.
*/
static void test_lpn_term_cb_check(void)
{
bt_mesh_test_setup();
bt_mesh_lpn_set(true);
ASSERT_OK(evt_wait(LPN_POLLED, K_MSEC(1000)), "Friend never polled");
bt_mesh_lpn_set(false);
if (!evt_wait(LPN_TERMINATED, K_SECONDS(30))) {
FAIL("LPN terminate CB triggered unexpectedly");
}
PASS();
}
#define TEST_CASE(role, name, description) \
{ \
.test_id = "friendship_" #role "_" #name, .test_descr = description, \
.test_post_init_f = test_##role##_init, .test_tick_f = bt_mesh_test_timeout, \
.test_id = "friendship_" #role "_" #name, \
.test_descr = description, \
.test_post_init_f = test_##role##_init, \
.test_tick_f = bt_mesh_test_timeout, \
.test_main_f = test_##role##_##name, \
}
@ -874,6 +896,7 @@ static const struct bst_test_instance test_connect[] = {
TEST_CASE(lpn, group, "LPN: receive on group addrs"),
TEST_CASE(lpn, loopback, "LPN: send to loopback addrs"),
TEST_CASE(lpn, disable, "LPN: disable LPN"),
TEST_CASE(lpn, term_cb_check, "LPN: no terminate cb trigger"),
TEST_CASE(other, msg, "Other mesh device: message exchange"),
TEST_CASE(other, group, "Other mesh device: send to group addrs"),

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Copyright 2022 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
# Check that the LPN terminate callback does not trigger when there is no established
# connection.
#
# This covers a corner case scenario where the LPN has received a friend offer, but has
# not yet established a connection. In this case the LPN terminate callback should not
# be triggered if the LPN is disabled, which is monitored by this test.
RunTest mesh_lpn_terminate_cb_check \
friendship_friend_est \
friendship_lpn_term_cb_check