Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: Host: Unit test for bt_le_cs_set_valid_chma…
Browse files Browse the repository at this point in the history
…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
weeTike authored and rlubos committed Nov 18, 2024
1 parent 26d1cc3 commit 90eeeeb
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
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 tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/prj.conf
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 tests/bluetooth/host/cs/bt_le_cs_set_valid_chmap_bits/src/main.c
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);
}
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

0 comments on commit 90eeeeb

Please sign in to comment.