Skip to content

Commit 90eeeeb

Browse files
weeTikerlubos
authored andcommitted
[nrf fromtree] Bluetooth: Host: Unit test for bt_le_cs_set_valid_chmap_bits
Add coverage of the bt_le_cs_set_valid_chmap_bits function to unit tests Signed-off-by: Timothy Keys <[email protected]> (cherry picked from commit e976a01) Signed-off-by: Sean Madigan <[email protected]>
1 parent 26d1cc3 commit 90eeeeb

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
7+
get_filename_component(project_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
8+
project(${project_name})
9+
10+
include_directories(BEFORE
11+
${ZEPHYR_BASE}/tests/bluetooth/host/cs/mocks
12+
)
13+
14+
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks)
15+
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/cs/mocks mocks)
16+
17+
target_link_libraries(testbinary PRIVATE mocks host_mocks)
18+
19+
target_sources(testbinary
20+
PRIVATE
21+
src/main.c
22+
23+
${ZEPHYR_BASE}/subsys/bluetooth/host/cs.c
24+
${ZEPHYR_BASE}/lib/net_buf/buf_simple.c
25+
${ZEPHYR_BASE}/subsys/logging/log_minimal.c
26+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_BT=y
3+
CONFIG_BT_HCI=y
4+
CONFIG_BT_CENTRAL=y
5+
CONFIG_BT_CHANNEL_SOUNDING=y
6+
CONFIG_ASSERT=y
7+
CONFIG_ASSERT_LEVEL=2
8+
CONFIG_ASSERT_VERBOSE=y
9+
CONFIG_ASSERT_ON_ERRORS=y
10+
CONFIG_NET_BUF=y
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/bluetooth/cs.h>
9+
#include <zephyr/fff.h>
10+
11+
DEFINE_FFF_GLOBALS;
12+
13+
ZTEST_SUITE(bt_le_cs_set_valid_chmap_bits, NULL, NULL, NULL, NULL, NULL);
14+
15+
/*
16+
* Test uninitialized chmap buffer is populated correctly
17+
*
18+
* Expected behaviour:
19+
* - test_chmap matches correct_chmap
20+
*/
21+
ZTEST(bt_le_cs_set_valid_chmap_bits, test_uninitialized_chmap)
22+
{
23+
uint8_t test_chmap[10];
24+
25+
bt_le_cs_set_valid_chmap_bits(test_chmap);
26+
27+
uint8_t correct_chmap[10] = {0xFC, 0xFF, 0x7F, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F};
28+
29+
zassert_mem_equal(test_chmap, correct_chmap, 10);
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
common:
2+
tags:
3+
- bluetooth
4+
- host
5+
tests:
6+
bluetooth.host.cs.bt_le_cs_set_valid_chmap_bits:
7+
type: unit

0 commit comments

Comments
 (0)