Skip to content

Commit 2e3ae01

Browse files
Andrewpinijhedberg
authored andcommitted
tests: Bluetooth: Mesh: LCD test all comp pages
Adds test for verifying split get operation for all composition data pages. Signed-off-by: Anders Storrø <[email protected]>
1 parent 57cb1b1 commit 2e3ae01

19 files changed

+434
-32
lines changed

tests/bsim/bluetooth/mesh/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ if(CONFIG_SETTINGS)
3030
src/test_dfu.c
3131
src/test_blob.c
3232
src/test_sar.c
33+
src/test_lcd.c
3334
)
3435
endif()
3536

@@ -78,7 +79,6 @@ else()
7879
src/test_blob.c
7980
src/test_op_agg.c
8081
src/test_sar.c
81-
src/test_lcd.c
8282
)
8383
endif()
8484

tests/bsim/bluetooth/mesh/overlay_pst.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ CONFIG_BT_MESH_SEQ_STORE_RATE=1
1919
CONFIG_BT_MESH_RPL_STORE_TIMEOUT=1
2020
CONFIG_BT_MESH_STORE_TIMEOUT=1
2121
CONFIG_BT_MESH_TX_SEG_RETRANS_COUNT=1
22+
CONFIG_BT_MESH_COMP_PST_BUF_SIZE=600

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern struct bst_test_list *test_provision_pst_install(struct bst_test_list *te
1414
#if defined(CONFIG_BT_MESH_V1d1)
1515
extern struct bst_test_list *test_dfu_install(struct bst_test_list *test);
1616
extern struct bst_test_list *test_blob_pst_install(struct bst_test_list *test);
17+
extern struct bst_test_list *test_lcd_install(struct bst_test_list *test);
1718
extern struct bst_test_list *test_sar_pst_install(struct bst_test_list *test);
1819
#endif /* defined(CONFIG_BT_MESH_V1d1) */
1920
#elif defined(CONFIG_BT_MESH_GATT_PROXY)
@@ -39,7 +40,6 @@ extern struct bst_test_list *test_adv_install(struct bst_test_list *test);
3940
extern struct bst_test_list *test_blob_install(struct bst_test_list *test);
4041
extern struct bst_test_list *test_op_agg_install(struct bst_test_list *test);
4142
extern struct bst_test_list *test_sar_install(struct bst_test_list *test);
42-
extern struct bst_test_list *test_lcd_install(struct bst_test_list *test);
4343
#endif /* defined(CONFIG_BT_MESH_V1d1) */
4444
#endif
4545

@@ -51,6 +51,7 @@ bst_test_install_t test_installers[] = {
5151
test_provision_pst_install,
5252
test_dfu_install,
5353
test_blob_pst_install,
54+
test_lcd_install,
5455
test_sar_pst_install,
5556
#endif /* defined(CONFIG_BT_MESH_V1d1) */
5657
#elif defined(CONFIG_BT_MESH_GATT_PROXY)
@@ -75,7 +76,6 @@ bst_test_install_t test_installers[] = {
7576
test_blob_install,
7677
test_op_agg_install,
7778
test_sar_install,
78-
test_lcd_install,
7979
#endif /* defined(CONFIG_BT_MESH_V1d1) */
8080
#endif
8181
NULL

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

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <mesh/access.h>
1717
#include <mesh/net.h>
18+
#include "argparse.h"
1819

1920
LOG_MODULE_REGISTER(test_lcd, LOG_LEVEL_INF);
2021

@@ -50,6 +51,41 @@ const struct bt_mesh_model_op dummy_op[] = {
5051
BT_MESH_MODEL_OP_END,
5152
};
5253

54+
static const uint8_t elem_offset2[3] = {4, 5, 6};
55+
static const uint8_t additional_data[2] = {100, 200}; /* A Mesh Profile may have additional data. */
56+
static const struct bt_mesh_comp2_record comp_rec[40] = {
57+
[0 ... 39] = {.id = 10,
58+
.version.x = 20,
59+
.version.y = 30,
60+
.version.z = 40,
61+
.elem_offset_cnt = sizeof(elem_offset2),
62+
.elem_offset = elem_offset2,
63+
.data_len = sizeof(additional_data),
64+
.data = additional_data},
65+
};
66+
static const struct bt_mesh_comp2 comp_p2 = {.record_cnt = ARRAY_SIZE(comp_rec),
67+
.record = comp_rec};
68+
69+
static int comp_page;
70+
static bool comp_changed;
71+
static void test_args_parse(int argc, char *argv[])
72+
{
73+
bs_args_struct_t args_struct[] = {
74+
{.dest = &comp_page,
75+
.type = 'i',
76+
.name = "{page}",
77+
.option = "page",
78+
.descript = "Current composition data page"},
79+
{.dest = &comp_changed,
80+
.type = 'b',
81+
.name = "{0, 1}",
82+
.option = "comp-changed-mode",
83+
.descript = "Composition data has changed"},
84+
};
85+
86+
bs_args_parse_all_cmd_line(argc, argv, args_struct);
87+
}
88+
5389
static struct bt_mesh_models_metadata_entry *dummy_meta_entry[] = {};
5490

5591
/* Empty elements to create large composition/meta data */
@@ -224,7 +260,7 @@ static void test_cli_max_sdu_comp_data_request(void)
224260
if (err && err != -E2BIG) {
225261
FAIL("CLIENT: Failed to get comp data Page 0: %d", err);
226262
}
227-
total_size = bt_mesh_comp_page_0_size();
263+
total_size = bt_mesh_comp_page_size(0);
228264

229265
/* Get server composition data and check integrity */
230266
ASSERT_OK(bt_mesh_large_comp_data_get(0, SRV_ADDR, page, offset, &srv_rsp));
@@ -238,12 +274,11 @@ static void test_cli_max_sdu_comp_data_request(void)
238274
static void test_cli_split_comp_data_request(void)
239275
{
240276
int err;
241-
uint8_t page = 0;
242-
uint16_t offset, total_size, prev_len = 0;
277+
uint16_t offset = 0, prev_len = 0;
243278

244-
NET_BUF_SIMPLE_DEFINE(local_comp, 200);
245-
NET_BUF_SIMPLE_DEFINE(srv_rsp_comp_1, 64);
246-
NET_BUF_SIMPLE_DEFINE(srv_rsp_comp_2, 64);
279+
NET_BUF_SIMPLE_DEFINE(local_comp, CONFIG_BT_MESH_COMP_PST_BUF_SIZE);
280+
NET_BUF_SIMPLE_DEFINE(srv_rsp_comp_1, 500);
281+
NET_BUF_SIMPLE_DEFINE(srv_rsp_comp_2, 500);
247282
net_buf_simple_init(&local_comp, 0);
248283
net_buf_simple_init(&srv_rsp_comp_1, 0);
249284
net_buf_simple_init(&srv_rsp_comp_2, 0);
@@ -255,32 +290,38 @@ static void test_cli_split_comp_data_request(void)
255290
.data = &srv_rsp_comp_2,
256291
};
257292

258-
bt_mesh_device_setup(&prov, &comp_1);
293+
bt_mesh_device_setup(&prov, (comp_page == 0 || comp_page == 128) ? &comp_1 : &comp_2);
294+
bt_mesh_comp2_register(&comp_p2);
259295
prov_and_conf(cli_cfg);
260-
target_node_alloc(comp_1, srv_cfg);
261-
262-
offset = 0;
296+
target_node_alloc((comp_page == 0 || comp_page == 128) ? comp_1 : comp_2, srv_cfg);
263297

264298
/* Get local data */
265-
err = bt_mesh_comp_data_get_page_0(&local_comp, offset);
299+
err = bt_mesh_comp_data_get_page(&local_comp, comp_page, 0);
266300
/* Operation is successful even if all data cannot fit in the buffer (-E2BIG) */
267301
if (err && err != -E2BIG) {
268-
FAIL("CLIENT: Failed to get comp data Page 0: %d", err);
302+
FAIL("CLIENT: Failed to get comp data Page %d: %d", err, comp_page);
269303
}
270-
total_size = bt_mesh_comp_page_0_size();
304+
305+
uint16_t total_size = bt_mesh_comp_page_size(comp_page);
306+
307+
/* Verify that the total comp page size is not larger than the provided buffer */
308+
ASSERT_TRUE(total_size <= CONFIG_BT_MESH_COMP_PST_BUF_SIZE);
309+
310+
/* Wait a bit until the server is ready to respond*/
311+
k_sleep(K_SECONDS(2));
271312

272313
/* Get first server composition data sample and verify data */
273-
ASSERT_OK(bt_mesh_large_comp_data_get(0, SRV_ADDR, page, offset, &srv_rsp_1));
274-
rsp_equals_local_data_assert(SRV_ADDR, &srv_rsp_1, &local_comp, page, offset, total_size,
275-
&prev_len);
314+
ASSERT_OK(bt_mesh_large_comp_data_get(0, SRV_ADDR, comp_page, offset, &srv_rsp_1));
315+
rsp_equals_local_data_assert(SRV_ADDR, &srv_rsp_1, &local_comp, comp_page, offset,
316+
total_size, &prev_len);
276317

277318
prev_len = srv_rsp_comp_1.len;
278-
offset += prev_len;
319+
offset = prev_len;
279320

280321
/* Get next server composition data sample */
281-
ASSERT_OK(bt_mesh_large_comp_data_get(0, SRV_ADDR, page, offset, &srv_rsp_2));
282-
rsp_equals_local_data_assert(SRV_ADDR, &srv_rsp_2, &local_comp, page, offset, total_size,
283-
&prev_len);
322+
ASSERT_OK(bt_mesh_large_comp_data_get(0, SRV_ADDR, comp_page, offset, &srv_rsp_2));
323+
rsp_equals_local_data_assert(SRV_ADDR, &srv_rsp_2, &local_comp, comp_page, offset,
324+
total_size, &prev_len);
284325

285326
/* Check data integrity of merged sample data */
286327
merge_and_compare_assert(&srv_rsp_comp_1, &srv_rsp_comp_2, &local_comp);
@@ -383,9 +424,16 @@ static void test_cli_split_metadata_request(void)
383424

384425
static void test_srv_comp_data_status_respond(void)
385426
{
386-
bt_mesh_device_setup(&prov, &comp_1);
427+
bt_mesh_device_setup(&prov, (comp_page == 0 || comp_page == 128) ? &comp_1 : &comp_2);
428+
bt_mesh_comp2_register(&comp_p2);
387429
prov_and_conf(srv_cfg);
388430

431+
/* Simulate an update of composition data */
432+
if (comp_changed) {
433+
bt_mesh_comp_change_prepare();
434+
atomic_set_bit(bt_mesh.flags, BT_MESH_COMP_DIRTY);
435+
}
436+
389437
/* No server callback available. Wait 10 sec for message to be recived */
390438
k_sleep(K_SECONDS(10));
391439

@@ -411,6 +459,7 @@ static void test_srv_metadata_status_respond(void)
411459
{ \
412460
.test_id = "lcd_" #role "_" #name, \
413461
.test_descr = description, \
462+
.test_args_f = test_args_parse, \
414463
.test_tick_f = bt_mesh_test_timeout, \
415464
.test_post_init_f = test_##role##_init, \
416465
.test_main_f = test_##role##_##name, \

tests/bsim/bluetooth/mesh/tests_scripts/large_comp_data/get_comp_data_split.sh renamed to tests/bsim/bluetooth/mesh/tests_scripts/large_comp_data/get_comp0_data_split.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
2020
# 6. Client merges the two samples and checks that the collected data is
2121
# correctly merged, continuous, and matches its local comp data.
2222
conf=prj_mesh1d1_conf
23-
RunTest mesh_lcd_test_split_comp_data \
24-
lcd_cli_split_comp_data_request lcd_srv_comp_data_status_respond
23+
overlay=overlay_pst_conf
24+
RunTest mesh_lcd_test_comp0_data_split \
25+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=0
2526

2627
conf=prj_mesh1d1_conf
27-
overlay=overlay_psa_conf
28-
RunTest mesh_lcd_test_split_comp_data_psa \
29-
lcd_cli_split_comp_data_request lcd_srv_comp_data_status_respond
28+
overlay="overlay_pst_conf_overlay_psa_conf"
29+
RunTest mesh_lcd_test_comp0_data_split \
30+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=0
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Nordic Semiconductor
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6+
7+
# Test that the LCD server model is able to split the
8+
# composition data when the total size exceeds the maximum access message size.
9+
# The test environment simulates a scenario where the server has completed DFU.
10+
#
11+
# Test procedure:
12+
# 0. Provisioning and setup. Server and client has same comp data.
13+
# 1. Client requests a sample exceeding the maximum avaialble payload from the
14+
# server's composition data.
15+
# 2. Client fetch its local comp data.
16+
# 3. When server status arrive, remove status field data and compare received
17+
# comp data with corresponding bytes in local comp data.
18+
# 4. Client requests the next sample from server's composition data.
19+
# 5. When server status arrive, remove status field data and compare received
20+
# comp data with correspending bytes in local comp data.
21+
# 6. Client merges the two samples and checks that the collected data is
22+
# correctly merged, continuous, and matches its local comp data.
23+
conf=prj_mesh1d1_conf
24+
overlay=overlay_pst_conf
25+
RunTest mesh_lcd_test_comp0_data_split_dfu \
26+
lcd_srv_comp_data_status_respond \
27+
lcd_cli_split_comp_data_request -- -argstest page=0 comp-changed-mode=1
28+
29+
conf=prj_mesh1d1_conf
30+
overlay="overlay_pst_conf_overlay_psa_conf"
31+
RunTest mesh_lcd_test_comp0_data_split_dfu \
32+
lcd_srv_comp_data_status_respond \
33+
lcd_cli_split_comp_data_request -- -argstest page=0 comp-changed-mode=1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Nordic Semiconductor
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6+
7+
# Test that the LCD server model is able to split the
8+
# composition data when the total size exceeds the maximum access message size.
9+
#
10+
# Test procedure:
11+
# 0. Provisioning and setup. Server and client has same comp data.
12+
# 1. Client requests a sample exceeding the maximum avaialble payload from the
13+
# server's composition data.
14+
# 2. Client fetch its local comp data.
15+
# 3. When server status arrive, remove status field data and compare received
16+
# comp data with corresponding bytes in local comp data.
17+
# 4. Client requests the next sample from server's composition data.
18+
# 5. When server status arrive, remove status field data and compare received
19+
# comp data with correspending bytes in local comp data.
20+
# 6. Client merges the two samples and checks that the collected data is
21+
# correctly merged, continuous, and matches its local comp data.
22+
conf=prj_mesh1d1_conf
23+
overlay=overlay_pst_conf
24+
RunTest mesh_lcd_test_comp128_data_split \
25+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=128
26+
27+
conf=prj_mesh1d1_conf
28+
overlay="overlay_pst_conf_overlay_psa_conf"
29+
RunTest mesh_lcd_test_comp128_data_split \
30+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=128
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Nordic Semiconductor
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6+
7+
# Test that the LCD server model is able to split the
8+
# composition data when the total size exceeds the maximum access message size.
9+
# The test environment simulates a scenario where the server has completed DFU.
10+
#
11+
# Test procedure:
12+
# 0. Provisioning and setup. Server and client has same comp data.
13+
# 1. Client requests a sample exceeding the maximum avaialble payload from the
14+
# server's composition data.
15+
# 2. Client fetch its local comp data.
16+
# 3. When server status arrive, remove status field data and compare received
17+
# comp data with corresponding bytes in local comp data.
18+
# 4. Client requests the next sample from server's composition data.
19+
# 5. When server status arrive, remove status field data and compare received
20+
# comp data with correspending bytes in local comp data.
21+
# 6. Client merges the two samples and checks that the collected data is
22+
# correctly merged, continuous, and matches its local comp data.
23+
conf=prj_mesh1d1_conf
24+
overlay=overlay_pst_conf
25+
RunTest mesh_lcd_test_comp128_data_split_dfu \
26+
lcd_srv_comp_data_status_respond \
27+
lcd_cli_split_comp_data_request -- -argstest page=128 comp-changed-mode=1
28+
29+
conf=prj_mesh1d1_conf
30+
overlay="overlay_pst_conf_overlay_psa_conf"
31+
RunTest mesh_lcd_test_comp128_data_split_dfu \
32+
lcd_srv_comp_data_status_respond \
33+
lcd_cli_split_comp_data_request -- -argstest page=128 comp-changed-mode=1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Nordic Semiconductor
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6+
7+
# Test that the LCD server model is able to split the
8+
# composition data when the total size exceeds the maximum access message size.
9+
#
10+
# Test procedure:
11+
# 0. Provisioning and setup. Server and client has same comp data.
12+
# 1. Client requests a sample exceeding the maximum avaialble payload from the
13+
# server's composition data.
14+
# 2. Client fetch its local comp data.
15+
# 3. When server status arrive, remove status field data and compare received
16+
# comp data with corresponding bytes in local comp data.
17+
# 4. Client requests the next sample from server's composition data.
18+
# 5. When server status arrive, remove status field data and compare received
19+
# comp data with correspending bytes in local comp data.
20+
# 6. Client merges the two samples and checks that the collected data is
21+
# correctly merged, continuous, and matches its local comp data.
22+
conf=prj_mesh1d1_conf
23+
overlay=overlay_pst_conf
24+
RunTest mesh_lcd_test_comp129_data_split \
25+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=129
26+
27+
conf=prj_mesh1d1_conf
28+
overlay="overlay_pst_conf_overlay_psa_conf"
29+
RunTest mesh_lcd_test_comp129_data_split \
30+
lcd_srv_comp_data_status_respond lcd_cli_split_comp_data_request -- -argstest page=129
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2023 Nordic Semiconductor
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
6+
7+
# Test that the LCD server model is able to split the
8+
# composition data when the total size exceeds the maximum access message size.
9+
# The test environment simulates a scenario where the server has completed DFU.
10+
#
11+
# Test procedure:
12+
# 0. Provisioning and setup. Server and client has same comp data.
13+
# 1. Client requests a sample exceeding the maximum avaialble payload from the
14+
# server's composition data.
15+
# 2. Client fetch its local comp data.
16+
# 3. When server status arrive, remove status field data and compare received
17+
# comp data with corresponding bytes in local comp data.
18+
# 4. Client requests the next sample from server's composition data.
19+
# 5. When server status arrive, remove status field data and compare received
20+
# comp data with correspending bytes in local comp data.
21+
# 6. Client merges the two samples and checks that the collected data is
22+
# correctly merged, continuous, and matches its local comp data.
23+
conf=prj_mesh1d1_conf
24+
overlay=overlay_pst_conf
25+
RunTest mesh_lcd_test_comp129_data_split_dfu \
26+
lcd_srv_comp_data_status_respond \
27+
lcd_cli_split_comp_data_request -- -argstest page=129 comp-changed-mode=1
28+
29+
conf=prj_mesh1d1_conf
30+
overlay="overlay_pst_conf_overlay_psa_conf"
31+
RunTest mesh_lcd_test_comp129_data_split_dfu \
32+
lcd_srv_comp_data_status_respond \
33+
lcd_cli_split_comp_data_request -- -argstest page=129 comp-changed-mode=1

0 commit comments

Comments
 (0)