1 /* main.c - Application main entry point */
2
3 /*
4 * Copyright (c) 2023-2024 Nordic Semiconductor ASA
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include <errno.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 #include <zephyr/bluetooth/audio/audio.h>
15 #include <zephyr/bluetooth/audio/bap.h>
16 #include <zephyr/bluetooth/audio/lc3.h>
17 #include <zephyr/bluetooth/byteorder.h>
18 #include <zephyr/bluetooth/hci_types.h>
19 #include <zephyr/bluetooth/iso.h>
20 #include <zephyr/fff.h>
21 #include <zephyr/kernel.h>
22 #include <zephyr/net_buf.h>
23 #include <zephyr/sys/printk.h>
24 #include <zephyr/sys/util_macro.h>
25
26 #include "bap_broadcast_source.h"
27 #include "bap_stream.h"
28 #include "bap_stream_expects.h"
29 #include "bluetooth.h"
30 #include "expects_util.h"
31 #include "ztest_assert.h"
32 #include "ztest_test.h"
33
34 DEFINE_FFF_GLOBALS;
35
mock_init_rule_before(const struct ztest_unit_test * test,void * fixture)36 static void mock_init_rule_before(const struct ztest_unit_test *test, void *fixture)
37 {
38 mock_bap_broadcast_source_init();
39 mock_bap_stream_init();
40 }
41
mock_destroy_rule_after(const struct ztest_unit_test * test,void * fixture)42 static void mock_destroy_rule_after(const struct ztest_unit_test *test, void *fixture)
43 {
44 mock_bap_stream_cleanup();
45 }
46
47 ZTEST_RULE(mock_rule, mock_init_rule_before, mock_destroy_rule_after);
48
49 struct bap_broadcast_source_test_suite_fixture {
50 struct bt_bap_broadcast_source_param *param;
51 size_t stream_cnt;
52 struct bt_bap_broadcast_source *source;
53 };
54
bap_broadcast_source_test_suite_fixture_init(struct bap_broadcast_source_test_suite_fixture * fixture)55 static void bap_broadcast_source_test_suite_fixture_init(
56 struct bap_broadcast_source_test_suite_fixture *fixture)
57 {
58 const uint8_t bis_cfg_data[] = {
59 BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_CHAN_ALLOC,
60 BT_BYTES_LIST_LE32(BT_AUDIO_LOCATION_FRONT_LEFT |
61 BT_AUDIO_LOCATION_FRONT_RIGHT)),
62 };
63 const size_t streams_per_subgroup = CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT /
64 CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT;
65 const enum bt_audio_context ctx = BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED;
66 const enum bt_audio_location loc = BT_AUDIO_LOCATION_FRONT_LEFT;
67 struct bt_bap_broadcast_source_subgroup_param *subgroup_param;
68 struct bt_bap_broadcast_source_stream_param *stream_params;
69 struct bt_audio_codec_cfg *codec_cfg;
70 struct bt_bap_qos_cfg *qos_cfg;
71 struct bt_bap_stream *streams;
72 const uint16_t latency = 10U; /* ms*/
73 const uint32_t pd = 40000U; /* us */
74 const uint16_t sdu = 40U; /* octets */
75 const uint8_t rtn = 2U;
76 uint8_t *bis_data;
77
78 zassert_true(streams_per_subgroup > 0U);
79 zassert_true(sizeof(bis_cfg_data) <= CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE);
80
81 /* Allocate memory for everything */
82 fixture->param = malloc(sizeof(struct bt_bap_broadcast_source_param));
83 subgroup_param = malloc(sizeof(struct bt_bap_broadcast_source_subgroup_param) *
84 CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT);
85 zassert_not_null(subgroup_param);
86 stream_params = malloc(sizeof(struct bt_bap_broadcast_source_stream_param) *
87 CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);
88 zassert_not_null(stream_params);
89 codec_cfg = malloc(sizeof(struct bt_audio_codec_cfg));
90 zassert_not_null(codec_cfg);
91 qos_cfg = malloc(sizeof(struct bt_bap_qos_cfg));
92 zassert_not_null(qos_cfg);
93 streams = malloc(sizeof(struct bt_bap_stream) * CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);
94 zassert_not_null(streams);
95 bis_data = malloc(CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE);
96 zassert_not_null(bis_data);
97
98 /* Memset everything to 0 */
99 memset(fixture->param, 0, sizeof(*fixture->param));
100 memset(subgroup_param, 0,
101 sizeof(struct bt_bap_broadcast_source_subgroup_param) *
102 CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT);
103 memset(stream_params, 0,
104 sizeof(struct bt_bap_broadcast_source_stream_param) *
105 CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);
106 memset(codec_cfg, 0, sizeof(struct bt_audio_codec_cfg));
107 memset(qos_cfg, 0, sizeof(struct bt_bap_qos_cfg));
108 memset(streams, 0, sizeof(struct bt_bap_stream) * CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT);
109 memset(bis_data, 0, CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE);
110
111 /* Initialize default values*/
112 *codec_cfg = BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ,
113 BT_AUDIO_CODEC_CFG_DURATION_10, loc, 40U, 1, ctx);
114 *qos_cfg = BT_BAP_QOS_CFG_UNFRAMED(10000u, sdu, rtn, latency, pd);
115 memcpy(bis_data, bis_cfg_data, sizeof(bis_cfg_data));
116
117 for (size_t i = 0U; i < CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT; i++) {
118 subgroup_param[i].params_count = streams_per_subgroup;
119 subgroup_param[i].params = stream_params + i * streams_per_subgroup;
120 subgroup_param[i].codec_cfg = codec_cfg;
121 }
122
123 for (size_t i = 0U; i < CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT; i++) {
124 stream_params[i].stream = &streams[i];
125 stream_params[i].data = bis_data;
126 stream_params[i].data_len = sizeof(bis_cfg_data);
127 bt_bap_stream_cb_register(stream_params[i].stream, &mock_bap_stream_ops);
128 }
129
130 fixture->param->params_count = CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT;
131 fixture->param->params = subgroup_param;
132 fixture->param->qos = qos_cfg;
133 fixture->param->encryption = false;
134 memset(fixture->param->broadcast_code, 0, sizeof(fixture->param->broadcast_code));
135 fixture->param->packing = BT_ISO_PACKING_SEQUENTIAL;
136
137 fixture->stream_cnt = fixture->param->params_count * streams_per_subgroup;
138 }
139
bap_broadcast_source_test_suite_setup(void)140 static void *bap_broadcast_source_test_suite_setup(void)
141 {
142 struct bap_broadcast_source_test_suite_fixture *fixture;
143
144 fixture = malloc(sizeof(*fixture));
145 zassert_not_null(fixture);
146
147 return fixture;
148 }
149
bap_broadcast_source_test_suite_before(void * f)150 static void bap_broadcast_source_test_suite_before(void *f)
151 {
152 int err;
153
154 memset(f, 0, sizeof(struct bap_broadcast_source_test_suite_fixture));
155 bap_broadcast_source_test_suite_fixture_init(f);
156
157 err = bt_bap_broadcast_source_register_cb(&mock_bap_broadcast_source_cb);
158 zassert_equal(0, err, "Unexpected return value %d", err);
159 }
160
bap_broadcast_source_test_suite_after(void * f)161 static void bap_broadcast_source_test_suite_after(void *f)
162 {
163 struct bap_broadcast_source_test_suite_fixture *fixture = f;
164 struct bt_bap_broadcast_source_param *param;
165
166 if (fixture->source != NULL) {
167 int err;
168
169 (void)bt_bap_broadcast_source_stop(fixture->source);
170
171 err = bt_bap_broadcast_source_delete(fixture->source);
172 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
173 fixture->source = NULL;
174 }
175
176 param = fixture->param;
177
178 free(param->params[0].params[0].data);
179 free(param->params[0].params[0].stream);
180 free(param->params[0].params);
181 free(param->params[0].codec_cfg);
182 free(param->params);
183 free(param->qos);
184 free(param);
185
186 bt_bap_broadcast_source_unregister_cb(&mock_bap_broadcast_source_cb);
187 }
188
bap_broadcast_source_test_suite_teardown(void * f)189 static void bap_broadcast_source_test_suite_teardown(void *f)
190 {
191 free(f);
192 }
193
194 ZTEST_SUITE(bap_broadcast_source_test_suite, NULL, bap_broadcast_source_test_suite_setup,
195 bap_broadcast_source_test_suite_before, bap_broadcast_source_test_suite_after,
196 bap_broadcast_source_test_suite_teardown);
197
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_delete)198 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_delete)
199 {
200 struct bt_bap_broadcast_source_param *create_param = fixture->param;
201 int err;
202
203 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
204 create_param->params_count, fixture->stream_cnt);
205
206 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
207 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
208
209 for (size_t i = 0u; i < create_param->params_count; i++) {
210 for (size_t j = 0u; j < create_param->params[i].params_count; j++) {
211 const struct bt_bap_stream *stream =
212 create_param->params[i].params[j].stream;
213
214 zassert_equal(create_param->qos->sdu, stream->qos->sdu,
215 "Unexpected stream SDU");
216 zassert_equal(create_param->qos->rtn, stream->qos->rtn,
217 "Unexpected stream RTN");
218 zassert_equal(create_param->qos->phy, stream->qos->phy,
219 "Unexpected stream PHY");
220 }
221 }
222
223 err = bt_bap_broadcast_source_delete(fixture->source);
224 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
225 fixture->source = NULL;
226 }
227
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_start_send_stop_delete)228 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_start_send_stop_delete)
229 {
230 struct bt_bap_broadcast_source_param *create_param = fixture->param;
231 struct bt_le_ext_adv ext_adv = {0};
232 int err;
233
234 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
235 create_param->params_count, fixture->stream_cnt);
236
237 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
238 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
239
240 err = bt_bap_broadcast_source_start(fixture->source, &ext_adv);
241 zassert_equal(0, err, "Unable to start broadcast source: err %d", err);
242
243 zexpect_call_count("bt_bap_stream_ops.connected", fixture->stream_cnt,
244 mock_bap_stream_connected_cb_fake.call_count);
245 zexpect_call_count("bt_bap_stream_ops.started", fixture->stream_cnt,
246 mock_bap_stream_started_cb_fake.call_count);
247 zexpect_call_count("bt_bap_broadcast_source_cb.started", 1,
248 mock_bap_broadcast_source_started_cb_fake.call_count);
249
250 for (size_t i = 0U; i < create_param->params_count; i++) {
251 for (size_t j = 0U; j < create_param->params[i].params_count; j++) {
252 struct bt_bap_stream *bap_stream = create_param->params[i].params[j].stream;
253
254 /* verify bap stream started cb stream parameter */
255 zassert_equal(mock_bap_stream_started_cb_fake.arg0_history[i], bap_stream);
256 struct bt_audio_codec_cfg *codec_cfg = bap_stream->codec_cfg;
257 enum bt_audio_location chan_allocation;
258 /* verify subgroup codec data */
259 zassert_equal(bt_audio_codec_cfg_get_freq(codec_cfg),
260 BT_AUDIO_CODEC_CFG_FREQ_16KHZ);
261 zassert_equal(bt_audio_codec_cfg_get_frame_dur(codec_cfg),
262 BT_AUDIO_CODEC_CFG_DURATION_10);
263 /* verify bis specific codec data */
264 bt_audio_codec_cfg_get_chan_allocation(codec_cfg, &chan_allocation, false);
265 zassert_equal(chan_allocation,
266 BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT);
267 /* Since BAP doesn't care about the `buf` we can just provide NULL */
268 err = bt_bap_stream_send(bap_stream, NULL, 0);
269 zassert_equal(0, err,
270 "Unable to send on broadcast stream[%zu][%zu]: err %d", i, j,
271 err);
272 }
273 }
274
275 zexpect_call_count("bt_bap_stream_ops.sent", fixture->stream_cnt,
276 mock_bap_stream_sent_cb_fake.call_count);
277
278 err = bt_bap_broadcast_source_stop(fixture->source);
279 zassert_equal(0, err, "Unable to stop broadcast source: err %d", err);
280
281 zexpect_call_count("bt_bap_stream_ops.disconnected", fixture->stream_cnt,
282 mock_bap_stream_disconnected_cb_fake.call_count);
283 zexpect_call_count("bt_bap_stream_ops.stopped", fixture->stream_cnt,
284 mock_bap_stream_stopped_cb_fake.call_count);
285 zexpect_call_count("bt_bap_broadcast_source_cb.stopped", 1,
286 mock_bap_broadcast_source_stopped_cb_fake.call_count);
287
288 err = bt_bap_broadcast_source_delete(fixture->source);
289 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
290 fixture->source = NULL;
291 }
292
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_param_null)293 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_param_null)
294 {
295 int err;
296
297 err = bt_bap_broadcast_source_create(NULL, &fixture->source);
298 zassert_not_equal(0, err, "Did not fail with null params");
299 }
300
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_source_null)301 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_source_null)
302 {
303 struct bt_bap_broadcast_source_param *create_param = fixture->param;
304 int err;
305
306 err = bt_bap_broadcast_source_create(create_param, NULL);
307 zassert_not_equal(0, err, "Did not fail with null source");
308 }
309
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_count_0)310 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_subgroup_params_count_0)
311 {
312 struct bt_bap_broadcast_source_param *create_param = fixture->param;
313 int err;
314
315 create_param->params_count = 0U;
316 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
317 zassert_not_equal(0, err, "Did not fail with params_count %u", create_param->params_count);
318 }
319
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_count_above_max)320 ZTEST_F(bap_broadcast_source_test_suite,
321 test_broadcast_source_create_inval_subgroup_params_count_above_max)
322 {
323 struct bt_bap_broadcast_source_param *create_param = fixture->param;
324 int err;
325
326 create_param->params_count = CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT + 1;
327 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
328 zassert_not_equal(0, err, "Did not fail with params_count %u", create_param->params_count);
329 }
330
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_null)331 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_subgroup_params_null)
332 {
333 struct bt_bap_broadcast_source_param *create_param = fixture->param;
334 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
335 int err;
336
337 create_param->params = NULL;
338 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
339 /* Restore the params for the cleanup after function */
340 create_param->params = subgroup_params;
341 zassert_not_equal(0, err, "Did not fail with NULL subgroup params");
342 }
343
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_qos_null)344 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_qos_null)
345 {
346 struct bt_bap_broadcast_source_param *create_param = fixture->param;
347 struct bt_bap_qos_cfg *qos = create_param->qos;
348 int err;
349
350 create_param->qos = NULL;
351 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
352 /* Restore the params for the cleanup after function */
353 create_param->qos = qos;
354 zassert_not_equal(0, err, "Did not fail with NULL qos");
355 }
356
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_packing)357 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_packing)
358 {
359 struct bt_bap_broadcast_source_param *create_param = fixture->param;
360 int err;
361
362 create_param->packing = 0x02;
363 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
364 zassert_not_equal(0, err, "Did not fail with packing %u", create_param->packing);
365 }
366
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_params_count_0)367 ZTEST_F(bap_broadcast_source_test_suite,
368 test_broadcast_source_create_inval_subgroup_params_params_count_0)
369 {
370 struct bt_bap_broadcast_source_param *create_param = fixture->param;
371 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
372 int err;
373
374 subgroup_params->params_count = 0U;
375 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
376 zassert_not_equal(0, err, "Did not fail with %u stream params",
377 subgroup_params->params_count);
378 }
379
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_params_count_above_max)380 ZTEST_F(bap_broadcast_source_test_suite,
381 test_broadcast_source_create_inval_subgroup_params_params_count_above_max)
382 {
383 struct bt_bap_broadcast_source_param *create_param = fixture->param;
384 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
385 int err;
386
387 subgroup_params->params_count = CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT + 1;
388 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
389 zassert_not_equal(0, err, "Did not fail with %u stream params",
390 subgroup_params->params_count);
391 }
392
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_stream_params_null)393 ZTEST_F(bap_broadcast_source_test_suite,
394 test_broadcast_source_create_inval_subgroup_params_stream_params_null)
395 {
396 struct bt_bap_broadcast_source_param *create_param = fixture->param;
397 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
398 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
399 int err;
400
401 subgroup_params->params = NULL;
402 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
403 /* Restore the params for the cleanup after function */
404 subgroup_params->params = stream_params;
405 zassert_not_equal(0, err, "Did not fail with NULL stream params");
406 }
407
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_codec_cfg_null)408 ZTEST_F(bap_broadcast_source_test_suite,
409 test_broadcast_source_create_inval_subgroup_params_codec_cfg_null)
410 {
411 struct bt_bap_broadcast_source_param *create_param = fixture->param;
412 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
413 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
414 int err;
415
416 subgroup_params->codec_cfg = NULL;
417 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
418 /* Restore the params for the cleanup after function */
419 subgroup_params->codec_cfg = codec_cfg;
420 zassert_not_equal(0, err, "Did not fail with NULL codec_cfg");
421 }
422
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_codec_cfg_data_len)423 ZTEST_F(bap_broadcast_source_test_suite,
424 test_broadcast_source_create_inval_subgroup_params_codec_cfg_data_len)
425 {
426 struct bt_bap_broadcast_source_param *create_param = fixture->param;
427 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
428 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
429 int err;
430
431 codec_cfg->data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
432 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
433 zassert_not_equal(0, err, "Did not fail with codec_cfg->data_len %zu", codec_cfg->data_len);
434 }
435
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_codec_cfg_meta_len)436 ZTEST_F(bap_broadcast_source_test_suite,
437 test_broadcast_source_create_inval_subgroup_params_codec_cfg_meta_len)
438 {
439 struct bt_bap_broadcast_source_param *create_param = fixture->param;
440 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
441 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
442 int err;
443
444 codec_cfg->meta_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE + 1;
445 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
446 zassert_not_equal(0, err, "Did not fail with codec_cfg->meta_len %zu", codec_cfg->meta_len);
447 }
448
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_codec_cfg_cid)449 ZTEST_F(bap_broadcast_source_test_suite,
450 test_broadcast_source_create_inval_subgroup_params_codec_cfg_cid)
451 {
452 struct bt_bap_broadcast_source_param *create_param = fixture->param;
453 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
454 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
455 int err;
456
457 codec_cfg->id = BT_HCI_CODING_FORMAT_LC3;
458 codec_cfg->cid = 0x01; /* Shall be 0 if id == 0x06 (LC3)*/
459 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
460 zassert_not_equal(0, err, "Did not fail with codec_cfg->cid %u", codec_cfg->cid);
461 }
462
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_subgroup_params_codec_cfg_vid)463 ZTEST_F(bap_broadcast_source_test_suite,
464 test_broadcast_source_create_inval_subgroup_params_codec_cfg_vid)
465 {
466 struct bt_bap_broadcast_source_param *create_param = fixture->param;
467 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
468 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
469 int err;
470
471 codec_cfg->id = BT_HCI_CODING_FORMAT_LC3;
472 codec_cfg->vid = 0x01; /* Shall be 0 if id == 0x06 (LC3)*/
473 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
474 zassert_not_equal(0, err, "Did not fail with codec_cfg->vid %u", codec_cfg->vid);
475 }
476
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_stream_params_stream_null)477 ZTEST_F(bap_broadcast_source_test_suite,
478 test_broadcast_source_create_inval_stream_params_stream_null)
479 {
480 struct bt_bap_broadcast_source_param *create_param = fixture->param;
481 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
482 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
483 struct bt_bap_stream *stream = stream_params->stream;
484 int err;
485
486 stream_params->stream = NULL;
487 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
488 /* Restore the params for the cleanup after function */
489 stream_params->stream = stream;
490 zassert_not_equal(0, err, "Did not fail with NULL stream_params->stream");
491 }
492
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_stream_params_data_null)493 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_stream_params_data_null)
494 {
495 struct bt_bap_broadcast_source_param *create_param = fixture->param;
496 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
497 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
498 uint8_t *data = stream_params->data;
499 int err;
500
501 stream_params->data = NULL;
502 stream_params->data_len = 1;
503 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
504 /* Restore the params for the cleanup after function */
505 stream_params->data = data;
506 zassert_not_equal(
507 0, err,
508 "Did not fail with NULL stream_params->data and stream_params_>data_len %zu",
509 stream_params->data_len);
510 }
511
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_create_inval_stream_params_data_len)512 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_inval_stream_params_data_len)
513 {
514 struct bt_bap_broadcast_source_param *create_param = fixture->param;
515 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = &create_param->params[0];
516 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
517 int err;
518
519 stream_params->data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
520 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
521 zassert_not_equal(0, err, "Did not fail with stream_params_>data_len %zu",
522 stream_params->data_len);
523 }
524
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_start_inval_source_null)525 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_start_inval_source_null)
526 {
527 struct bt_bap_broadcast_source_param *create_param = fixture->param;
528 struct bt_le_ext_adv ext_adv = {0};
529 int err;
530
531 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
532 create_param->params_count, fixture->stream_cnt);
533
534 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
535 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
536
537 err = bt_bap_broadcast_source_start(NULL, &ext_adv);
538 zassert_not_equal(0, err, "Did not fail with null source");
539 }
540
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_start_inval_ext_adv_null)541 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_start_inval_ext_adv_null)
542 {
543 struct bt_bap_broadcast_source_param *create_param = fixture->param;
544 int err;
545
546 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
547 create_param->params_count, fixture->stream_cnt);
548
549 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
550 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
551
552 err = bt_bap_broadcast_source_start(fixture->source, NULL);
553 zassert_not_equal(0, err, "Did not fail with null ext_adv");
554 }
555
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_start_inval_double_start)556 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_start_inval_double_start)
557 {
558 struct bt_bap_broadcast_source_param *create_param = fixture->param;
559 struct bt_le_ext_adv ext_adv = {0};
560 int err;
561
562 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
563 create_param->params_count, fixture->stream_cnt);
564
565 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
566 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
567
568 err = bt_bap_broadcast_source_start(fixture->source, &ext_adv);
569 zassert_equal(0, err, "Unable to start broadcast source: err %d", err);
570
571 err = bt_bap_broadcast_source_start(fixture->source, &ext_adv);
572 zassert_not_equal(0, err, "Did not fail with starting already started source");
573 }
574
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_single_subgroup)575 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_single_subgroup)
576 {
577 struct bt_bap_broadcast_source_param *reconf_param = fixture->param;
578 const size_t subgroup_cnt = reconf_param->params_count;
579 int err;
580
581 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
582 reconf_param->params_count, fixture->stream_cnt);
583
584 err = bt_bap_broadcast_source_create(reconf_param, &fixture->source);
585 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
586
587 for (size_t i = 0u; i < reconf_param->params_count; i++) {
588 for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
589 const struct bt_bap_stream *stream =
590 reconf_param->params[i].params[j].stream;
591
592 zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
593 "Unexpected stream SDU");
594 zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
595 "Unexpected stream RTN");
596 zassert_equal(reconf_param->qos->phy, stream->qos->phy,
597 "Unexpected stream PHY");
598 }
599 }
600
601 reconf_param->params_count = 1U;
602 reconf_param->qos->sdu = 100U;
603 reconf_param->qos->rtn = 3U;
604 reconf_param->qos->phy = 1U;
605
606 err = bt_bap_broadcast_source_reconfig(fixture->source, reconf_param);
607 zassert_equal(0, err, "Unable to reconfigure broadcast source: err %d", err);
608
609 for (size_t i = 0u; i < subgroup_cnt; i++) {
610 for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
611 const struct bt_bap_stream *stream =
612 reconf_param->params[i].params[j].stream;
613
614 zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
615 "Unexpected stream SDU");
616 zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
617 "Unexpected stream RTN");
618 zassert_equal(reconf_param->qos->phy, stream->qos->phy,
619 "Unexpected stream PHY");
620 }
621 }
622
623 err = bt_bap_broadcast_source_delete(fixture->source);
624 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
625 fixture->source = NULL;
626 }
627
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_all)628 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_all)
629 {
630 struct bt_bap_broadcast_source_param *reconf_param = fixture->param;
631 int err;
632
633 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
634 reconf_param->params_count, fixture->stream_cnt);
635
636 err = bt_bap_broadcast_source_create(reconf_param, &fixture->source);
637 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
638
639 for (size_t i = 0u; i < reconf_param->params_count; i++) {
640 for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
641 const struct bt_bap_stream *stream =
642 reconf_param->params[i].params[j].stream;
643
644 zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
645 "Unexpected stream SDU");
646 zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
647 "Unexpected stream RTN");
648 zassert_equal(reconf_param->qos->phy, stream->qos->phy,
649 "Unexpected stream PHY");
650 }
651 }
652
653 reconf_param->qos->sdu = 100U;
654 reconf_param->qos->rtn = 3U;
655 reconf_param->qos->phy = 1U;
656
657 err = bt_bap_broadcast_source_reconfig(fixture->source, reconf_param);
658 zassert_equal(0, err, "Unable to reconfigure broadcast source: err %d", err);
659
660 for (size_t i = 0u; i < reconf_param->params_count; i++) {
661 for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
662 const struct bt_bap_stream *stream =
663 reconf_param->params[i].params[j].stream;
664
665 zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
666 "Unexpected stream SDU");
667 zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
668 "Unexpected stream RTN");
669 zassert_equal(reconf_param->qos->phy, stream->qos->phy,
670 "Unexpected stream PHY");
671 }
672 }
673
674 err = bt_bap_broadcast_source_delete(fixture->source);
675 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
676 fixture->source = NULL;
677 }
678
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_param_null)679 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_inval_param_null)
680 {
681 struct bt_bap_broadcast_source_param *param = fixture->param;
682 int err;
683
684 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
685 param->params_count, fixture->stream_cnt);
686
687 err = bt_bap_broadcast_source_create(param, &fixture->source);
688 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
689
690 err = bt_bap_broadcast_source_reconfig(fixture->source, NULL);
691 zassert_not_equal(0, err, "Did not fail with null params");
692
693 err = bt_bap_broadcast_source_delete(fixture->source);
694 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
695 fixture->source = NULL;
696 }
697
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_source_null)698 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_inval_source_null)
699 {
700 struct bt_bap_broadcast_source_param *param = fixture->param;
701 int err;
702
703 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
704 param->params_count, fixture->stream_cnt);
705
706 err = bt_bap_broadcast_source_create(param, &fixture->source);
707 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
708
709 err = bt_bap_broadcast_source_reconfig(NULL, param);
710 zassert_not_equal(0, err, "Did not fail with null source");
711
712 err = bt_bap_broadcast_source_delete(fixture->source);
713 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
714 fixture->source = NULL;
715 }
716
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_count_0)717 ZTEST_F(bap_broadcast_source_test_suite,
718 test_broadcast_source_reconfigure_inval_subgroup_params_count_0)
719 {
720 struct bt_bap_broadcast_source_param *param = fixture->param;
721 int err;
722
723 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
724 param->params_count, fixture->stream_cnt);
725
726 err = bt_bap_broadcast_source_create(param, &fixture->source);
727 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
728
729 param->params_count = 0U;
730 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
731 zassert_not_equal(0, err, "Did not fail with params_count %u", param->params_count);
732
733 err = bt_bap_broadcast_source_delete(fixture->source);
734 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
735 fixture->source = NULL;
736 }
737
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_count_above_max)738 ZTEST_F(bap_broadcast_source_test_suite,
739 test_broadcast_source_reconfigure_inval_subgroup_params_count_above_max)
740 {
741 struct bt_bap_broadcast_source_param *param = fixture->param;
742 int err;
743
744 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
745 param->params_count, fixture->stream_cnt);
746
747 err = bt_bap_broadcast_source_create(param, &fixture->source);
748 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
749
750 param->params_count = CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT + 1;
751 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
752 zassert_not_equal(0, err, "Did not fail with params_count %u", param->params_count);
753
754 err = bt_bap_broadcast_source_delete(fixture->source);
755 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
756 fixture->source = NULL;
757 }
758
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_null)759 ZTEST_F(bap_broadcast_source_test_suite,
760 test_broadcast_source_reconfigure_inval_subgroup_params_null)
761 {
762 struct bt_bap_broadcast_source_param *param = fixture->param;
763 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
764 int err;
765
766 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
767 param->params_count, fixture->stream_cnt);
768
769 err = bt_bap_broadcast_source_create(param, &fixture->source);
770 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
771
772 param->params = NULL;
773 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
774 /* Restore the params for the cleanup after function */
775 param->params = subgroup_params;
776 zassert_not_equal(0, err, "Did not fail with NULL subgroup params");
777
778 err = bt_bap_broadcast_source_delete(fixture->source);
779 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
780 fixture->source = NULL;
781 }
782
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_qos_null)783 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_inval_qos_null)
784 {
785 struct bt_bap_broadcast_source_param *param = fixture->param;
786 struct bt_bap_qos_cfg *qos = param->qos;
787 int err;
788
789 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
790 param->params_count, fixture->stream_cnt);
791
792 err = bt_bap_broadcast_source_create(param, &fixture->source);
793 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
794
795 param->qos = NULL;
796 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
797 /* Restore the params for the cleanup after function */
798 param->qos = qos;
799 zassert_not_equal(0, err, "Did not fail with NULL qos");
800
801 err = bt_bap_broadcast_source_delete(fixture->source);
802 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
803 fixture->source = NULL;
804 }
805
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_packing)806 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_inval_packing)
807 {
808 struct bt_bap_broadcast_source_param *param = fixture->param;
809 int err;
810
811 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
812 param->params_count, fixture->stream_cnt);
813
814 err = bt_bap_broadcast_source_create(param, &fixture->source);
815 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
816
817 param->packing = 0x02;
818 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
819 zassert_not_equal(0, err, "Did not fail with packing %u", param->packing);
820
821 err = bt_bap_broadcast_source_delete(fixture->source);
822 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
823 fixture->source = NULL;
824 }
825
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_params_count_0)826 ZTEST_F(bap_broadcast_source_test_suite,
827 test_broadcast_source_reconfigure_inval_subgroup_params_params_count_0)
828 {
829 struct bt_bap_broadcast_source_param *param = fixture->param;
830 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
831 int err;
832
833 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
834 param->params_count, fixture->stream_cnt);
835
836 err = bt_bap_broadcast_source_create(param, &fixture->source);
837 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
838
839 subgroup_params->params_count = 0U;
840 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
841 zassert_not_equal(0, err, "Did not fail with %u stream params",
842 subgroup_params->params_count);
843
844 err = bt_bap_broadcast_source_delete(fixture->source);
845 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
846 fixture->source = NULL;
847 }
848
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_params_count_above_max)849 ZTEST_F(bap_broadcast_source_test_suite,
850 test_broadcast_source_reconfigure_inval_subgroup_params_params_count_above_max)
851 {
852 struct bt_bap_broadcast_source_param *param = fixture->param;
853 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
854 int err;
855
856 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
857 param->params_count, fixture->stream_cnt);
858
859 err = bt_bap_broadcast_source_create(param, &fixture->source);
860 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
861
862 subgroup_params->params_count = CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT + 1;
863 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
864 zassert_not_equal(0, err, "Did not fail with %u stream params",
865 subgroup_params->params_count);
866
867 err = bt_bap_broadcast_source_delete(fixture->source);
868 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
869 fixture->source = NULL;
870 }
871
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_stream_params_null)872 ZTEST_F(bap_broadcast_source_test_suite,
873 test_broadcast_source_reconfigure_inval_subgroup_params_stream_params_null)
874 {
875 struct bt_bap_broadcast_source_param *param = fixture->param;
876 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
877 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
878 int err;
879
880 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
881 param->params_count, fixture->stream_cnt);
882
883 err = bt_bap_broadcast_source_create(param, &fixture->source);
884 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
885
886 subgroup_params->params = NULL;
887 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
888 /* Restore the params for the cleanup after function */
889 subgroup_params->params = stream_params;
890 zassert_not_equal(0, err, "Did not fail with NULL stream params");
891
892 err = bt_bap_broadcast_source_delete(fixture->source);
893 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
894 fixture->source = NULL;
895 }
896
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_null)897 ZTEST_F(bap_broadcast_source_test_suite,
898 test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_null)
899 {
900 struct bt_bap_broadcast_source_param *param = fixture->param;
901 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
902 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
903 int err;
904
905 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
906 param->params_count, fixture->stream_cnt);
907
908 err = bt_bap_broadcast_source_create(param, &fixture->source);
909 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
910
911 subgroup_params->codec_cfg = NULL;
912 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
913 /* Restore the params for the cleanup after function */
914 subgroup_params->codec_cfg = codec_cfg;
915 zassert_not_equal(0, err, "Did not fail with NULL codec_cfg");
916
917 err = bt_bap_broadcast_source_delete(fixture->source);
918 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
919 fixture->source = NULL;
920 }
921
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_data_len)922 ZTEST_F(bap_broadcast_source_test_suite,
923 test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_data_len)
924 {
925 struct bt_bap_broadcast_source_param *param = fixture->param;
926 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
927 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
928 int err;
929
930 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
931 param->params_count, fixture->stream_cnt);
932
933 err = bt_bap_broadcast_source_create(param, &fixture->source);
934 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
935
936 codec_cfg->data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
937 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
938 zassert_not_equal(0, err, "Did not fail with codec_cfg->data_len %zu", codec_cfg->data_len);
939
940 err = bt_bap_broadcast_source_delete(fixture->source);
941 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
942 fixture->source = NULL;
943 }
944
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_meta_len)945 ZTEST_F(bap_broadcast_source_test_suite,
946 test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_meta_len)
947 {
948 struct bt_bap_broadcast_source_param *param = fixture->param;
949 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
950 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
951 int err;
952
953 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
954 param->params_count, fixture->stream_cnt);
955
956 err = bt_bap_broadcast_source_create(param, &fixture->source);
957 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
958
959 codec_cfg->meta_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE + 1;
960 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
961 zassert_not_equal(0, err, "Did not fail with codec_cfg->meta_len %zu", codec_cfg->meta_len);
962
963 err = bt_bap_broadcast_source_delete(fixture->source);
964 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
965 fixture->source = NULL;
966 }
967
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_cid)968 ZTEST_F(bap_broadcast_source_test_suite,
969 test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_cid)
970 {
971 struct bt_bap_broadcast_source_param *param = fixture->param;
972 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
973 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
974 int err;
975
976 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
977 param->params_count, fixture->stream_cnt);
978
979 err = bt_bap_broadcast_source_create(param, &fixture->source);
980 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
981
982 codec_cfg->id = 0x06;
983 codec_cfg->cid = 0x01; /* Shall be 0 if id == 0x06 (LC3)*/
984 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
985 zassert_not_equal(0, err, "Did not fail with codec_cfg->cid %u", codec_cfg->cid);
986
987 err = bt_bap_broadcast_source_delete(fixture->source);
988 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
989 fixture->source = NULL;
990 }
991
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_vid)992 ZTEST_F(bap_broadcast_source_test_suite,
993 test_broadcast_source_reconfigure_inval_subgroup_params_codec_cfg_vid)
994 {
995 struct bt_bap_broadcast_source_param *param = fixture->param;
996 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
997 struct bt_audio_codec_cfg *codec_cfg = subgroup_params->codec_cfg;
998 int err;
999
1000 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1001 param->params_count, fixture->stream_cnt);
1002
1003 err = bt_bap_broadcast_source_create(param, &fixture->source);
1004 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1005
1006 codec_cfg->id = 0x06;
1007 codec_cfg->vid = 0x01; /* Shall be 0 if id == 0x06 (LC3)*/
1008 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
1009 zassert_not_equal(0, err, "Did not fail with codec_cfg->vid %u", codec_cfg->vid);
1010
1011 err = bt_bap_broadcast_source_delete(fixture->source);
1012 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1013 fixture->source = NULL;
1014 }
1015
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_stream_params_stream_null)1016 ZTEST_F(bap_broadcast_source_test_suite,
1017 test_broadcast_source_reconfigure_inval_stream_params_stream_null)
1018 {
1019 struct bt_bap_broadcast_source_param *param = fixture->param;
1020 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
1021 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
1022 struct bt_bap_stream *stream = stream_params->stream;
1023 int err;
1024
1025 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1026 param->params_count, fixture->stream_cnt);
1027
1028 err = bt_bap_broadcast_source_create(param, &fixture->source);
1029 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1030
1031 stream_params->stream = NULL;
1032 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
1033 /* Restore the params for the cleanup after function */
1034 stream_params->stream = stream;
1035 zassert_not_equal(0, err, "Did not fail with NULL stream_params->stream");
1036
1037 err = bt_bap_broadcast_source_delete(fixture->source);
1038 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1039 fixture->source = NULL;
1040 }
1041
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_stream_params_data_null)1042 ZTEST_F(bap_broadcast_source_test_suite,
1043 test_broadcast_source_reconfigure_inval_stream_params_data_null)
1044 {
1045 struct bt_bap_broadcast_source_param *param = fixture->param;
1046 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
1047 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
1048 uint8_t *data = stream_params->data;
1049 int err;
1050
1051 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1052 param->params_count, fixture->stream_cnt);
1053
1054 err = bt_bap_broadcast_source_create(param, &fixture->source);
1055 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1056
1057 stream_params->data = NULL;
1058 stream_params->data_len = 1;
1059 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
1060 /* Restore the params for the cleanup after function */
1061 stream_params->data = data;
1062 zassert_not_equal(
1063 0, err,
1064 "Did not fail with NULL stream_params->data and stream_params_>data_len %zu",
1065 stream_params->data_len);
1066
1067 err = bt_bap_broadcast_source_delete(fixture->source);
1068 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1069 fixture->source = NULL;
1070 }
1071
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_stream_params_data_len)1072 ZTEST_F(bap_broadcast_source_test_suite,
1073 test_broadcast_source_reconfigure_inval_stream_params_data_len)
1074 {
1075 struct bt_bap_broadcast_source_param *param = fixture->param;
1076 struct bt_bap_broadcast_source_subgroup_param *subgroup_params = ¶m->params[0];
1077 struct bt_bap_broadcast_source_stream_param *stream_params = &subgroup_params->params[0];
1078 int err;
1079
1080 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1081 param->params_count, fixture->stream_cnt);
1082
1083 err = bt_bap_broadcast_source_create(param, &fixture->source);
1084 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1085
1086 stream_params->data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
1087 err = bt_bap_broadcast_source_reconfig(fixture->source, param);
1088 zassert_not_equal(0, err, "Did not fail with stream_params_>data_len %zu",
1089 stream_params->data_len);
1090
1091 err = bt_bap_broadcast_source_delete(fixture->source);
1092 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1093 fixture->source = NULL;
1094 }
1095
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_reconfigure_inval_state)1096 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_inval_state)
1097 {
1098 struct bt_bap_broadcast_source_param *param = fixture->param;
1099 struct bt_bap_broadcast_source *source;
1100 int err;
1101
1102 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1103 param->params_count, fixture->stream_cnt);
1104
1105 err = bt_bap_broadcast_source_create(param, &fixture->source);
1106 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1107 source = fixture->source;
1108
1109 err = bt_bap_broadcast_source_delete(fixture->source);
1110 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1111 fixture->source = NULL;
1112
1113 err = bt_bap_broadcast_source_reconfig(source, param);
1114 zassert_not_equal(0, err, "Did not fail with deleted broadcast source");
1115 }
1116
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_stop_inval_source_null)1117 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_stop_inval_source_null)
1118 {
1119 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1120 struct bt_le_ext_adv ext_adv = {0};
1121 int err;
1122
1123 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1124 create_param->params_count, fixture->stream_cnt);
1125
1126 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1127 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1128
1129 err = bt_bap_broadcast_source_start(fixture->source, &ext_adv);
1130 zassert_equal(0, err, "Unable to start broadcast source: err %d", err);
1131
1132 err = bt_bap_broadcast_source_stop(NULL);
1133 zassert_not_equal(0, err, "Did not fail with null source");
1134 }
1135
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_stop_inval_state)1136 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_stop_inval_state)
1137 {
1138 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1139 struct bt_le_ext_adv ext_adv = {0};
1140 int err;
1141
1142 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1143 create_param->params_count, fixture->stream_cnt);
1144
1145 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1146 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1147
1148 err = bt_bap_broadcast_source_start(fixture->source, &ext_adv);
1149 zassert_equal(0, err, "Unable to start broadcast source: err %d", err);
1150
1151 err = bt_bap_broadcast_source_stop(fixture->source);
1152 zassert_equal(0, err, "Unable to stop broadcast source: err %d", err);
1153
1154 err = bt_bap_broadcast_source_stop(NULL);
1155 zassert_not_equal(0, err, "Did not fail with stopping already stopped source");
1156 }
1157
1158
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_delete_inval_source_null)1159 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_delete_inval_source_null)
1160 {
1161 int err;
1162
1163 err = bt_bap_broadcast_source_delete(NULL);
1164 zassert_not_equal(0, err, "Did not fail with null source");
1165 }
1166
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_delete_inval_double_start)1167 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_delete_inval_double_start)
1168 {
1169 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1170 struct bt_bap_broadcast_source *source;
1171 int err;
1172
1173 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1174 create_param->params_count, fixture->stream_cnt);
1175
1176 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1177 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1178
1179 err = bt_bap_broadcast_source_delete(fixture->source);
1180 zassert_equal(0, err, "Unable to start broadcast source: err %d", err);
1181
1182 source = fixture->source;
1183 /* Set to NULL to avoid deleting it in bap_broadcast_source_test_suite_after */
1184 fixture->source = NULL;
1185
1186 err = bt_bap_broadcast_source_delete(source);
1187 zassert_not_equal(0, err, "Did not fail with deleting already deleting source");
1188 }
1189
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_single_bis)1190 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_single_bis)
1191 {
1192 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1193 int err;
1194
1195 const uint8_t expected_base[] = {
1196 0x51, 0x18, /* uuid */
1197 0x40, 0x9C, 0x00, /* pd */
1198 0x01, /* subgroup count */
1199 0x01, /* bis count */
1200 0x06, 0x00, 0x00, 0x00, 0x00, /* LC3 codec_id*/
1201 0x10, /* cc length */
1202 0x02, 0x01, 0x03, 0x02, 0x02, 0x01, 0x05, 0x03,
1203 0x01, 0x00, 0x00, 0x00, 0x03, 0x04, 0x28, 0x00, /* cc */
1204 0x04, /* meta length */
1205 0x03, 0x02, 0x01, 0x00, /* meta */
1206 0x01, /* bis index */
1207 0x06, /* bis cc length */
1208 0x05, 0x03, 0x03, 0x00, 0x00, 0x00 /* bis cc length */
1209 };
1210
1211 NET_BUF_SIMPLE_DEFINE(base_buf, 64);
1212
1213 /* Make the create param simpler for verification */
1214 create_param->params_count = 1U;
1215 create_param->params[0].params_count = 1U;
1216
1217 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1218 create_param->params_count, fixture->stream_cnt);
1219
1220 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1221 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1222
1223 err = bt_bap_broadcast_source_get_base(fixture->source, &base_buf);
1224 zassert_equal(0, err, "Unable to get broadcast source BASE: err %d", err);
1225
1226 zassert_equal(sizeof(expected_base), base_buf.len, "Incorrect base_buf.len %u, expected %u",
1227 base_buf.len, sizeof(expected_base));
1228
1229 /* Use memcmp to print the buffers if they are not identical as zassert_mem_equal does not
1230 * do that
1231 */
1232 if (memcmp(expected_base, base_buf.data, base_buf.len) != 0) {
1233 for (size_t i = 0U; i < base_buf.len; i++) {
1234 printk("[%zu]: 0x%02X %s 0x%02X\n", i, expected_base[i],
1235 expected_base[i] == base_buf.data[i] ? "==" : "!=",
1236 base_buf.data[i]);
1237 }
1238
1239 zassert_mem_equal(expected_base, base_buf.data, base_buf.len);
1240 }
1241
1242 err = bt_bap_broadcast_source_delete(fixture->source);
1243 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1244 fixture->source = NULL;
1245 }
1246
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base)1247 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base)
1248 {
1249 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1250 int err;
1251
1252 const uint8_t expected_base[] = {
1253 0x51, 0x18, /* uuid */
1254 0x40, 0x9C, 0x00, /* pd */
1255 0x02, /* subgroup count */
1256 0x01, /* Subgroup 1: bis count */
1257 0x06, 0x00, 0x00, 0x00, 0x00, /* LC3 codec_id*/
1258 0x10, /* cc length */
1259 0x02, 0x01, 0x03, 0x02, 0x02, 0x01, 0x05, 0x03,
1260 0x01, 0x00, 0x00, 0x00, 0x03, 0x04, 0x28, 0x00, /* cc */
1261 0x04, /* meta length */
1262 0x03, 0x02, 0x01, 0x00, /* meta */
1263 0x01, /* bis index */
1264 0x06, /* bis cc length */
1265 0x05, 0x03, 0x03, 0x00, 0x00, 0x00, /* bis cc length */
1266 0x01, /* Subgroup 1: bis count */
1267 0x06, 0x00, 0x00, 0x00, 0x00, /* LC3 codec_id*/
1268 0x10, /* cc length */
1269 0x02, 0x01, 0x03, 0x02, 0x02, 0x01, 0x05, 0x03,
1270 0x01, 0x00, 0x00, 0x00, 0x03, 0x04, 0x28, 0x00, /* cc */
1271 0x04, /* meta length */
1272 0x03, 0x02, 0x01, 0x00, /* meta */
1273 0x02, /* bis index */
1274 0x06, /* bis cc length */
1275 0x05, 0x03, 0x03, 0x00, 0x00, 0x00 /* bis cc length */
1276 };
1277
1278 NET_BUF_SIMPLE_DEFINE(base_buf, 128);
1279
1280 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1281 create_param->params_count, fixture->stream_cnt);
1282
1283 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1284 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1285
1286 err = bt_bap_broadcast_source_get_base(fixture->source, &base_buf);
1287 zassert_equal(0, err, "Unable to get broadcast source BASE: err %d", err);
1288
1289 zassert_equal(sizeof(expected_base), base_buf.len, "Incorrect base_buf.len %u, expected %u",
1290 base_buf.len, sizeof(expected_base));
1291
1292 /* Use memcmp to print the buffers if they are not identical as zassert_mem_equal does not
1293 * do that
1294 */
1295 if (memcmp(expected_base, base_buf.data, base_buf.len) != 0) {
1296 for (size_t i = 0U; i < base_buf.len; i++) {
1297 printk("[%zu]: 0x%02X %s 0x%02X\n", i, expected_base[i],
1298 expected_base[i] == base_buf.data[i] ? "==" : "!=",
1299 base_buf.data[i]);
1300 }
1301
1302 zassert_mem_equal(expected_base, base_buf.data, base_buf.len);
1303 }
1304
1305 err = bt_bap_broadcast_source_delete(fixture->source);
1306 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1307 fixture->source = NULL;
1308 }
1309
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_inval_source_null)1310 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_inval_source_null)
1311 {
1312 int err;
1313
1314 NET_BUF_SIMPLE_DEFINE(base_buf, 64);
1315
1316 err = bt_bap_broadcast_source_get_base(NULL, &base_buf);
1317 zassert_not_equal(0, err, "Did not fail with null source");
1318 }
1319
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_inval_base_buf_null)1320 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_inval_base_buf_null)
1321 {
1322 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1323 int err;
1324
1325 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1326 create_param->params_count, fixture->stream_cnt);
1327
1328 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1329 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1330
1331 err = bt_bap_broadcast_source_get_base(fixture->source, NULL);
1332 zassert_not_equal(0, err, "Did not fail with null BASE buffer");
1333
1334 err = bt_bap_broadcast_source_delete(fixture->source);
1335 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1336 fixture->source = NULL;
1337 }
1338
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_inval_state)1339 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_inval_state)
1340 {
1341 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1342 struct bt_bap_broadcast_source *source;
1343 int err;
1344
1345 NET_BUF_SIMPLE_DEFINE(base_buf, 64);
1346
1347 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1348 create_param->params_count, fixture->stream_cnt);
1349
1350 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1351 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1352
1353 source = fixture->source;
1354
1355 err = bt_bap_broadcast_source_delete(fixture->source);
1356 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1357 fixture->source = NULL;
1358
1359 err = bt_bap_broadcast_source_get_base(source, &base_buf);
1360 zassert_not_equal(0, err, "Did not fail with deleted broadcast source");
1361 }
1362
1363 /** This tests that providing a buffer too small for _any_ BASE fails correctly */
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_inval_very_small_buf)1364 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_inval_very_small_buf)
1365 {
1366 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1367 int err;
1368
1369 NET_BUF_SIMPLE_DEFINE(base_buf, 15); /* Too small to hold any BASE */
1370
1371 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1372 create_param->params_count, fixture->stream_cnt);
1373
1374 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1375 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1376
1377 err = bt_bap_broadcast_source_get_base(fixture->source, &base_buf);
1378 zassert_not_equal(0, err, "Did not fail with too small base_buf (%u)", base_buf.size);
1379
1380 err = bt_bap_broadcast_source_delete(fixture->source);
1381 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1382 fixture->source = NULL;
1383 }
1384
1385 /** This tests that providing a buffer too small for the BASE we want to setup fails correctly */
ZTEST_F(bap_broadcast_source_test_suite,test_broadcast_source_get_base_inval_small_buf)1386 ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_get_base_inval_small_buf)
1387 {
1388 struct bt_bap_broadcast_source_param *create_param = fixture->param;
1389 int err;
1390
1391 /* Can hold a base, but not large enough for this configuration */
1392 NET_BUF_SIMPLE_DEFINE(base_buf, 64);
1393
1394 printk("Creating broadcast source with %zu subgroups with %zu streams\n",
1395 create_param->params_count, fixture->stream_cnt);
1396
1397 err = bt_bap_broadcast_source_create(create_param, &fixture->source);
1398 zassert_equal(0, err, "Unable to create broadcast source: err %d", err);
1399
1400 err = bt_bap_broadcast_source_get_base(fixture->source, &base_buf);
1401 zassert_not_equal(0, err, "Did not fail with too small base_buf (%u)", base_buf.size);
1402
1403 err = bt_bap_broadcast_source_delete(fixture->source);
1404 zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
1405 fixture->source = NULL;
1406 }
1407