Skip to content

Commit eaf92a1

Browse files
Thalleynashif
authored andcommitted
tests: Bluetooth: CAP: Initiator unicast start unittests
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 <[email protected]>
1 parent d97cc46 commit eaf92a1

File tree

9 files changed

+496
-128
lines changed

9 files changed

+496
-128
lines changed

subsys/bluetooth/audio/cap_initiator.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,8 @@ void bt_cap_initiator_codec_configured(struct bt_cap_stream *cap_stream)
978978
if (free_conn != NULL) {
979979
*free_conn = stream_conn;
980980
} else {
981-
__ASSERT_PRINT("No free conns");
981+
__ASSERT(false, "[%zu]: No free conns", i);
982+
return;
982983
}
983984
}
984985

tests/bluetooth/audio/cap_initiator/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ target_include_directories(testbinary PRIVATE include)
1414

1515
target_sources(testbinary
1616
PRIVATE
17-
${ZEPHYR_BASE}/subsys/bluetooth/host/uuid.c
1817
src/main.c
1918
src/test_common.c
19+
src/test_unicast_start.c
2020
)

tests/bluetooth/audio/cap_initiator/prj.conf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ CONFIG_LOG=y
33

44
CONFIG_BT=y
55
CONFIG_BT_CENTRAL=y
6-
CONFIG_BT_MAX_CONN=2
76
CONFIG_BT_AUDIO=y
87

98
# Dependencies for CAP initiator unicast
@@ -13,6 +12,13 @@ CONFIG_BT_CSIP_SET_COORDINATOR=y
1312
CONFIG_BT_CAP_INITIATOR=y
1413
CONFIG_BT_CAP_INITIATOR_LOG_LEVEL_DBG=y
1514

15+
# Support setting up a sink and source stream on 2 acceptors
16+
CONFIG_BT_MAX_CONN=2
17+
CONFIG_BT_ISO_MAX_CHAN=4
18+
CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=4
19+
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2
20+
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2
21+
1622
CONFIG_ASSERT=y
1723
CONFIG_ASSERT_LEVEL=2
1824
CONFIG_ASSERT_VERBOSE=y

tests/bluetooth/audio/cap_initiator/src/test_common.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* SPDX-License-Identifier: Apache-2.0
77
*/
88

9+
#include <zephyr/bluetooth/conn.h>
10+
#include <zephyr/bluetooth/hci_types.h>
11+
912
#include "cap_initiator.h"
1013
#include "conn.h"
1114
#include "test_common.h"
@@ -24,7 +27,7 @@ void test_conn_init(struct bt_conn *conn)
2427
{
2528
conn->index = 0;
2629
conn->info.type = BT_CONN_TYPE_LE;
27-
conn->info.role = BT_CONN_ROLE_PERIPHERAL;
30+
conn->info.role = BT_CONN_ROLE_CENTRAL;
2831
conn->info.state = BT_CONN_STATE_CONNECTED;
2932
conn->info.security.level = BT_SECURITY_L2;
3033
conn->info.security.enc_key_size = BT_ENC_KEY_SIZE_MAX;

0 commit comments

Comments
 (0)