From e2086c22bce26655923cceb6cae82da7c16205b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Wed, 1 Feb 2023 12:55:54 +0100 Subject: [PATCH] tests: Bluetooth: Mesh: Test SAR with slowest possible timings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test that sends longest possible PDU with slowest possible timings and default retransmission values. Signed-off-by: Krzysztof Kopyściński --- tests/bluetooth/bsim/mesh/src/test_sar.c | 67 +++++++++++++++++-- .../tests_scripts/sar/slow_transfer_test.sh | 19 ++++++ 2 files changed, 79 insertions(+), 7 deletions(-) create mode 100755 tests/bluetooth/bsim/mesh/tests_scripts/sar/slow_transfer_test.sh diff --git a/tests/bluetooth/bsim/mesh/src/test_sar.c b/tests/bluetooth/bsim/mesh/src/test_sar.c index 44b13e44856..5b35f0173aa 100644 --- a/tests/bluetooth/bsim/mesh/src/test_sar.c +++ b/tests/bluetooth/bsim/mesh/src/test_sar.c @@ -56,6 +56,23 @@ static struct bt_mesh_sar_rx test_sar_rx = { .ack_retrans_count = 3, }; +static struct bt_mesh_sar_tx test_sar_slow_tx = { + .seg_int_step = 15, + .unicast_retrans_count = CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_COUNT, + .unicast_retrans_without_prog_count = + CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_WITHOUT_PROG_COUNT, + .unicast_retrans_int_step = 15, + .unicast_retrans_int_inc = 15, +}; + +static struct bt_mesh_sar_rx test_sar_slow_rx = { + .seg_thresh = 0x1f, + .ack_delay_inc = 7, + .discard_timeout = CONFIG_BT_MESH_SAR_RX_DISCARD_TIMEOUT, + .rx_seg_int_step = 15, + .ack_retrans_count = CONFIG_BT_MESH_SAR_RX_ACK_RETRANS_COUNT, +}; + static struct bt_mesh_prov prov; static struct bt_mesh_cfg_cli cfg_cli; static struct bt_mesh_sar_cfg_cli sar_cli; @@ -139,7 +156,9 @@ static const struct bt_mesh_comp comp = { .elem_count = ARRAY_SIZE(elements), }; -static void prov_and_conf(uint16_t addr) +static void prov_and_conf(uint16_t addr, + struct bt_mesh_sar_rx *sar_rx_config, + struct bt_mesh_sar_tx *sar_tx_config) { int err; uint8_t status; @@ -160,8 +179,8 @@ static void prov_and_conf(uint16_t addr) status); } - ASSERT_OK(bt_mesh_sar_cfg_cli_transmitter_set(0, addr, &test_sar_tx, &tx_rsp)); - ASSERT_OK(bt_mesh_sar_cfg_cli_receiver_set(0, addr, &test_sar_rx, &rx_rsp)); + ASSERT_OK(bt_mesh_sar_cfg_cli_transmitter_set(0, addr, sar_tx_config, &tx_rsp)); + ASSERT_OK(bt_mesh_sar_cfg_cli_receiver_set(0, addr, sar_rx_config, &rx_rsp)); } static void array_random_fill(uint8_t array[], uint16_t len, int seed) @@ -173,11 +192,12 @@ static void array_random_fill(uint8_t array[], uint16_t len, int seed) } } -static void test_cli_max_len_sdu_send(void) +static void cli_max_len_sdu_send(struct bt_mesh_sar_rx *sar_rx_config, + struct bt_mesh_sar_tx *sar_tx_config) { bt_mesh_test_cfg_set(NULL, WAIT_TIME); bt_mesh_device_setup(&prov, &comp); - prov_and_conf(CLI_ADDR); + prov_and_conf(CLI_ADDR, sar_rx_config, sar_tx_config); ASSERT_OK(k_sem_init(&inst_suspend_sem, 0, 1)); array_random_fill(dummy_msg, ARRAY_SIZE(dummy_msg), RAND_SEED); @@ -194,11 +214,12 @@ static void test_cli_max_len_sdu_send(void) PASS(); } -static void test_srv_max_len_sdu_receive(void) +static void srv_max_len_sdu_receive(struct bt_mesh_sar_rx *sar_rx_config, + struct bt_mesh_sar_tx *sar_tx_config) { bt_mesh_test_cfg_set(NULL, WAIT_TIME); bt_mesh_device_setup(&prov, &comp); - prov_and_conf(SRV_ADDR); + prov_and_conf(SRV_ADDR, sar_rx_config, sar_tx_config); ASSERT_OK(k_sem_init(&inst_suspend_sem, 0, 1)); array_random_fill(dummy_msg, ARRAY_SIZE(dummy_msg), RAND_SEED); @@ -211,6 +232,34 @@ static void test_srv_max_len_sdu_receive(void) PASS(); } +static void test_cli_max_len_sdu_send(void) +{ + cli_max_len_sdu_send(&test_sar_rx, &test_sar_tx); + + PASS(); +} + +static void test_srv_max_len_sdu_receive(void) +{ + srv_max_len_sdu_receive(&test_sar_rx, &test_sar_tx); + + PASS(); +} + +static void test_cli_max_len_sdu_slow_send(void) +{ + cli_max_len_sdu_send(&test_sar_slow_rx, &test_sar_slow_tx); + + PASS(); +} + +static void test_srv_max_len_sdu_slow_receive(void) +{ + srv_max_len_sdu_receive(&test_sar_slow_rx, &test_sar_slow_tx); + + PASS(); +} + #define TEST_CASE(role, name, description) \ { \ .test_id = "sar_" #role "_" #name, \ @@ -224,6 +273,10 @@ static const struct bst_test_instance test_sar[] = { "Send a 32-segment message with pre-defined test SAR configurations"), TEST_CASE(srv, max_len_sdu_receive, "Receive a 32-segment message with pre-defined test SAR configurations."), + TEST_CASE(cli, max_len_sdu_slow_send, + "Send a 32-segment message with SAR configured with slowest timings."), + TEST_CASE(srv, max_len_sdu_slow_receive, + "Receive a 32-segment message with with SAR configured with slowest timings."), BSTEST_END_MARKER}; diff --git a/tests/bluetooth/bsim/mesh/tests_scripts/sar/slow_transfer_test.sh b/tests/bluetooth/bsim/mesh/tests_scripts/sar/slow_transfer_test.sh new file mode 100755 index 00000000000..47ee7205455 --- /dev/null +++ b/tests/bluetooth/bsim/mesh/tests_scripts/sar/slow_transfer_test.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Copyright 2023 Nordic Semiconductor +# SPDX-License-Identifier: Apache-2.0 + +source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh + +# Test that a maximum length SDU can be processed with SAR, +# even with transmitter and receiver configured with longest possible +# intervals and default retransmission counts. +# Test procedure: +# 1. Initialize Client and Server instances. +# 2. Bind "dummy" vendor model to both instances. +# 3. Configure SAR transmitter and receiver states. +# 4. The Client sends a Get-message with a maximum length SDU, targeting the server. +# 5. The Server responds with a maximum length SDU Status-message. +# 6. The test passes when the Client successfully receives the Status response. +conf=prj_mesh1d1_conf +RunTest sar_slow_test \ + sar_cli_max_len_sdu_slow_send sar_srv_max_len_sdu_slow_receive