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 <timothy.keys@nordicsemi.no>
This commit is contained in:
Timothy Keys 2024-10-31 15:08:18 +00:00 committed by Anas Nashif
commit e976a01bed
4 changed files with 73 additions and 0 deletions

View file

@ -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
)

View file

@ -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

View file

@ -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);
}

View file

@ -0,0 +1,7 @@
common:
tags:
- bluetooth
- host
tests:
bluetooth.host.cs.bt_le_cs_set_valid_chmap_bits:
type: unit