Skip to content

Commit

Permalink
tests: Bluetooth: CAP: Initiator unicast start unittests
Browse files Browse the repository at this point in the history
Adds unittests for the CAP Initiator start procedure, simply
verifying that the procedure works as well as
testing invalid parameters.
This also allows us to remove the invalid behavior checks
from the babblesim test implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley authored and nashif committed Aug 26, 2024
1 parent d97cc46 commit eaf92a1
Show file tree
Hide file tree
Showing 9 changed files with 496 additions and 128 deletions.
3 changes: 2 additions & 1 deletion subsys/bluetooth/audio/cap_initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ void bt_cap_initiator_codec_configured(struct bt_cap_stream *cap_stream)
if (free_conn != NULL) {
*free_conn = stream_conn;
} else {
__ASSERT_PRINT("No free conns");
__ASSERT(false, "[%zu]: No free conns", i);
return;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bluetooth/audio/cap_initiator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ target_include_directories(testbinary PRIVATE include)

target_sources(testbinary
PRIVATE
${ZEPHYR_BASE}/subsys/bluetooth/host/uuid.c
src/main.c
src/test_common.c
src/test_unicast_start.c
)
8 changes: 7 additions & 1 deletion tests/bluetooth/audio/cap_initiator/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ CONFIG_LOG=y

CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_AUDIO=y

# Dependencies for CAP initiator unicast
Expand All @@ -13,6 +12,13 @@ CONFIG_BT_CSIP_SET_COORDINATOR=y
CONFIG_BT_CAP_INITIATOR=y
CONFIG_BT_CAP_INITIATOR_LOG_LEVEL_DBG=y

# Support setting up a sink and source stream on 2 acceptors
CONFIG_BT_MAX_CONN=2
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=4
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2

CONFIG_ASSERT=y
CONFIG_ASSERT_LEVEL=2
CONFIG_ASSERT_VERBOSE=y
5 changes: 4 additions & 1 deletion tests/bluetooth/audio/cap_initiator/src/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/hci_types.h>

#include "cap_initiator.h"
#include "conn.h"
#include "test_common.h"
Expand All @@ -24,7 +27,7 @@ void test_conn_init(struct bt_conn *conn)
{
conn->index = 0;
conn->info.type = BT_CONN_TYPE_LE;
conn->info.role = BT_CONN_ROLE_PERIPHERAL;
conn->info.role = BT_CONN_ROLE_CENTRAL;
conn->info.state = BT_CONN_STATE_CONNECTED;
conn->info.security.level = BT_SECURITY_L2;
conn->info.security.enc_key_size = BT_ENC_KEY_SIZE_MAX;
Expand Down
Loading

0 comments on commit eaf92a1

Please sign in to comment.