Skip to content

Commit 94a2905

Browse files
committed
tests: Bluetooth: ISO: Add err test for bt_iso_cig_terminate
Add additional check in iso_disconnected to verify that bt_iso_cig_terminate will fail if we have connected CIS. Signed-off-by: Emil Gydesen <[email protected]>
1 parent b75f069 commit 94a2905

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/bsim/bluetooth/host/iso/cis/src/cis_central.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <errno.h>
78
#include <stddef.h>
89
#include <stdint.h>
910

@@ -30,6 +31,7 @@
3031

3132
extern enum bst_result_t bst_result;
3233
static struct bt_iso_chan iso_chans[CONFIG_BT_ISO_MAX_CHAN];
34+
static size_t connected_channels;
3335
static struct bt_iso_chan *default_chan = &iso_chans[0];
3436
static struct bt_iso_cig *cig;
3537
static uint16_t seq_num;
@@ -129,6 +131,8 @@ static void iso_connected(struct bt_iso_chan *chan)
129131
seq_num = 0U;
130132
enqueue_cnt = ENQUEUE_COUNT;
131133

134+
connected_channels++;
135+
132136
if (chan == default_chan) {
133137
/* Start send timer */
134138
k_work_schedule(&iso_send_work, K_MSEC(0));
@@ -146,6 +150,10 @@ static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
146150

147151
printk("ISO Channel %p disconnected (reason 0x%02x)\n", chan, reason);
148152

153+
TEST_ASSERT(connected_channels > 0U, "Unexpected connected_channels: %zu",
154+
connected_channels);
155+
connected_channels--;
156+
149157
if (chan == default_chan) {
150158
k_work_cancel_delayable(&iso_send_work);
151159

@@ -159,6 +167,14 @@ static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason)
159167
printk("Channel disconnected early, bumping seq_num to 1000 to end test\n");
160168
seq_num = 1000;
161169
}
170+
171+
if (connected_channels >= 1U) {
172+
/* Test if bt_iso_cig_terminate correctly fails when there are CIS connected */
173+
err = bt_iso_cig_terminate(cig);
174+
if (err != EINVAL) {
175+
TEST_FAIL("Unexpected success for terminate CIG");
176+
}
177+
}
162178
}
163179

164180
static void sdu_sent_cb(struct bt_iso_chan *chan)

0 commit comments

Comments
 (0)