-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrf fromtree] Bluetooth: Host: Unit test for bt_le_cs_set_valid_chma…
…p_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]>
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
||
get_filename_component(project_name ${CMAKE_CURRENT_SOURCE_DIR} NAME) | ||
project(${project_name}) | ||
|
||
include_directories(BEFORE | ||
${ZEPHYR_BASE}/tests/bluetooth/host/cs/mocks | ||
) | ||
|
||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host host_mocks) | ||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/host/cs/mocks mocks) | ||
|
||
target_link_libraries(testbinary PRIVATE mocks host_mocks) | ||
|
||
target_sources(testbinary | ||
PRIVATE | ||
src/main.c | ||
|
||
${ZEPHYR_BASE}/subsys/bluetooth/host/cs.c | ||
${ZEPHYR_BASE}/lib/net_buf/buf_simple.c | ||
${ZEPHYR_BASE}/subsys/logging/log_minimal.c | ||
) |
10 changes: 10 additions & 0 deletions
10
tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/prj.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_BT=y | ||
CONFIG_BT_HCI=y | ||
CONFIG_BT_CENTRAL=y | ||
CONFIG_BT_CHANNEL_SOUNDING=y | ||
CONFIG_ASSERT=y | ||
CONFIG_ASSERT_LEVEL=2 | ||
CONFIG_ASSERT_VERBOSE=y | ||
CONFIG_ASSERT_ON_ERRORS=y | ||
CONFIG_NET_BUF=y |
30 changes: 30 additions & 0 deletions
30
tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/src/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/bluetooth/cs.h> | ||
#include <zephyr/fff.h> | ||
|
||
DEFINE_FFF_GLOBALS; | ||
|
||
ZTEST_SUITE(bt_le_cs_set_valid_chmap_bits, NULL, NULL, NULL, NULL, NULL); | ||
|
||
/* | ||
* Test uninitialized chmap buffer is populated correctly | ||
* | ||
* Expected behaviour: | ||
* - test_chmap matches correct_chmap | ||
*/ | ||
ZTEST(bt_le_cs_set_valid_chmap_bits, test_uninitialized_chmap) | ||
{ | ||
uint8_t test_chmap[10]; | ||
|
||
bt_le_cs_set_valid_chmap_bits(test_chmap); | ||
|
||
uint8_t correct_chmap[10] = {0xFC, 0xFF, 0x7F, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F}; | ||
|
||
zassert_mem_equal(test_chmap, correct_chmap, 10); | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/testcase.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
common: | ||
tags: | ||
- bluetooth | ||
- host | ||
tests: | ||
bluetooth.host.cs.bt_le_cs_set_valid_chmap_bits: | ||
type: unit |