tests: Bluetooth: BAP: Update test for bt_bap_broadcast_source_reconfig

Added additional testing for bt_bap_broadcast_source_reconfig after
the API changed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-08-17 13:18:48 +02:00 committed by Fabio Baltieri
commit 6dd90c1ab0

View file

@ -100,14 +100,14 @@ static struct bt_bap_stream_ops stream_ops = {
static uint8_t valid_bis_codec_data[] = {BT_AUDIO_CODEC_DATA(
BT_AUDIO_CODEC_CONFIG_LC3_FREQ, BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ))};
static void broadcast_source_create_inval_reset_param(
struct bt_bap_broadcast_source_create_param *param,
struct bt_bap_broadcast_source_subgroup_param *subgroup_param,
struct bt_bap_broadcast_source_stream_param *stream_param)
static void
broadcast_source_inval_reset_param(struct bt_bap_broadcast_source_param *param,
struct bt_bap_broadcast_source_subgroup_param *subgroup_param,
struct bt_bap_broadcast_source_stream_param *stream_param)
{
struct bt_bap_broadcast_source_stream_param valid_stream_param;
struct bt_bap_broadcast_source_subgroup_param valid_subgroup_param;
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
valid_stream_param.stream = &broadcast_source_streams[0];
valid_stream_param.data_len = ARRAY_SIZE(valid_bis_codec_data);
@ -133,12 +133,12 @@ static void broadcast_source_create_inval_reset_param(
static void broadcast_source_create_inval_stream_param(void)
{
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_bap_broadcast_source *broadcast_source;
int err;
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Set data NULL while count is 1 */
stream_param.data = NULL;
@ -151,7 +151,7 @@ static void broadcast_source_create_inval_stream_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Initialize codec configuration data that is too large */
stream_param.data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
@ -166,7 +166,7 @@ static void broadcast_source_create_inval_stream_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Set stream to NULL */
stream_param.stream = NULL;
@ -179,7 +179,7 @@ static void broadcast_source_create_inval_stream_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE < 255) {
uint8_t bis_codec_data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1] = {0};
@ -205,13 +205,13 @@ static void broadcast_source_create_inval_stream_param(void)
static void broadcast_source_create_inval_subgroup_codec_param(void)
{
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_bap_broadcast_source *broadcast_source;
struct bt_audio_codec_cfg codec_cfg;
int err;
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg =
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
@ -225,7 +225,7 @@ static void broadcast_source_create_inval_subgroup_codec_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg =
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
@ -240,8 +240,7 @@ static void broadcast_source_create_inval_subgroup_codec_param(void)
}
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE < 255) {
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param,
&stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg = memcpy(&codec_cfg, &preset_16_2_1.codec_cfg,
sizeof(preset_16_2_1.codec_cfg));
@ -260,8 +259,7 @@ static void broadcast_source_create_inval_subgroup_codec_param(void)
}
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE < 255) {
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param,
&stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg = memcpy(&codec_cfg, &preset_16_2_1.codec_cfg,
sizeof(preset_16_2_1.codec_cfg));
@ -283,12 +281,12 @@ static void broadcast_source_create_inval_subgroup_codec_param(void)
static void broadcast_source_create_inval_subgroup_param(void)
{
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_bap_broadcast_source *broadcast_source;
int err;
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Set count to 0 */
subgroup_param.params_count = 0;
@ -309,7 +307,7 @@ static void broadcast_source_create_inval_subgroup_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Set params to NULL */
subgroup_param.params = NULL;
@ -320,7 +318,7 @@ static void broadcast_source_create_inval_subgroup_param(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
/* Set codec to NULL */
subgroup_param.codec_cfg = NULL;
@ -339,7 +337,7 @@ static void broadcast_source_create_inval(void)
{
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
struct bt_bap_broadcast_source *broadcast_sources[CONFIG_BT_BAP_BROADCAST_SRC_COUNT + 1U];
struct bt_audio_codec_qos qos;
int err;
@ -367,7 +365,7 @@ static void broadcast_source_create_inval(void)
broadcast_source_create_inval_subgroup_param();
/* Invalid create_param values */
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
create_param.params_count = 0;
printk("Test bt_bap_broadcast_source_create with 0 params_count\n");
@ -377,7 +375,7 @@ static void broadcast_source_create_inval(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
create_param.params = NULL;
printk("Test bt_bap_broadcast_source_create with NULL params\n");
@ -387,7 +385,7 @@ static void broadcast_source_create_inval(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
create_param.packing = 0x35;
printk("Test bt_bap_broadcast_source_create with packing 0x%02X\n", create_param.packing);
@ -397,7 +395,7 @@ static void broadcast_source_create_inval(void)
return;
}
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
create_param.qos = NULL;
printk("Test bt_bap_broadcast_source_create with NULL qos\n");
@ -408,7 +406,7 @@ static void broadcast_source_create_inval(void)
}
/* Invalid QoS values */
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
create_param.qos = memcpy(&qos, &preset_16_2_1.qos, sizeof(preset_16_2_1.qos));
qos.phy = BT_AUDIO_CODEC_QOS_CODED + 1;
@ -497,7 +495,7 @@ static void broadcast_source_create_inval(void)
}
/* Exceeding memory limits */
broadcast_source_create_inval_reset_param(&create_param, &subgroup_param, &stream_param);
broadcast_source_inval_reset_param(&create_param, &subgroup_param, &stream_param);
printk("Test bt_bap_broadcast_source_create with %zu broadcast sources\n",
ARRAY_SIZE(broadcast_sources));
@ -540,13 +538,15 @@ static void broadcast_source_create_inval(void)
static int setup_broadcast_source(struct bt_bap_broadcast_source **source)
{
uint8_t bis_codec_data[] = {3, BT_AUDIO_CODEC_CONFIG_LC3_FREQ,
BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ)};
uint8_t bis_codec_data[] = {
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FREQ,
BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ)),
};
struct bt_bap_broadcast_source_stream_param
stream_params[ARRAY_SIZE(broadcast_source_streams)];
struct bt_bap_broadcast_source_subgroup_param
subgroup_params[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
struct bt_bap_broadcast_source_create_param create_param;
struct bt_bap_broadcast_source_param create_param;
int err;
(void)memset(broadcast_source_streams, 0,
@ -570,7 +570,7 @@ static int setup_broadcast_source(struct bt_bap_broadcast_source **source)
create_param.params_count = ARRAY_SIZE(subgroup_params);
create_param.params = subgroup_params;
create_param.qos = &preset_16_2_2.qos;
create_param.qos = &preset_16_2_1.qos;
create_param.packing = BT_ISO_PACKING_SEQUENTIAL;
create_param.encryption = false;
@ -739,111 +739,328 @@ static int setup_extended_adv(struct bt_bap_broadcast_source *source, struct bt_
static void test_broadcast_source_reconfig_inval_state(struct bt_bap_broadcast_source *source)
{
uint8_t bis_codec_data[] = {
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FREQ,
BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ)),
};
struct bt_bap_broadcast_source_stream_param
stream_params[ARRAY_SIZE(broadcast_source_streams)];
struct bt_bap_broadcast_source_subgroup_param
subgroup_params[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
struct bt_bap_broadcast_source_param reconfig_param;
int err;
for (size_t i = 0; i < ARRAY_SIZE(stream_params); i++) {
stream_params[i].stream = &broadcast_source_streams[i];
bt_bap_stream_cb_register(stream_params[i].stream, &stream_ops);
stream_params[i].data_len = sizeof(bis_codec_data);
stream_params[i].data = bis_codec_data;
}
for (size_t i = 0U; i < ARRAY_SIZE(subgroup_params); i++) {
subgroup_params[i].params_count = 1U;
subgroup_params[i].params = &stream_params[i];
subgroup_params[i].codec_cfg = &preset_16_2_2.codec_cfg;
}
reconfig_param.params_count = ARRAY_SIZE(subgroup_params);
reconfig_param.params = subgroup_params;
reconfig_param.qos = &preset_16_2_2.qos;
reconfig_param.packing = BT_ISO_PACKING_SEQUENTIAL;
reconfig_param.encryption = false;
printk("Test bt_bap_broadcast_source_reconfig in stopped state\n");
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg,
&preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig in stopped state did not fail\n");
return;
}
}
static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source *source)
static void
test_broadcast_source_reconfig_inval_stream_param(struct bt_bap_broadcast_source *broadcast_source)
{
struct bt_audio_codec_qos qos;
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_param reconfig_param;
struct bt_bap_broadcast_source_stream_param stream_param;
int err;
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Set data NULL while count is 1 */
stream_param.data = NULL;
printk("Test bt_bap_broadcast_source_reconfig with NULL stream_param\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL stream_param data did not "
"fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Initialize codec configuration data that is too large */
stream_param.data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
printk("Test bt_bap_broadcast_source_reconfig with stream_param.data_len %zu\n",
stream_param.data_len);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with stream_param data count %u "
"did not fail\n",
stream_param.data_len);
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Set stream to NULL */
stream_param.stream = NULL;
printk("Test bt_bap_broadcast_source_reconfig with NULL stream_param.stream\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL stream_param stream "
"did not fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE < 255) {
uint8_t bis_codec_data[sizeof(sizeof(valid_bis_codec_data))];
memcpy(bis_codec_data, valid_bis_codec_data, sizeof(valid_bis_codec_data));
/* Set LTV data to invalid size */
stream_param.data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
stream_param.data = bis_codec_data;
printk("Test bt_bap_broadcast_source_reconfig with CC LTV size %zu\n",
sizeof(bis_codec_data));
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with CC LTV size %zu in "
"stream_param did not fail\n",
sizeof(bis_codec_data));
return;
}
}
}
static void test_broadcast_source_reconfig_inval_subgroup_codec_param(
struct bt_bap_broadcast_source *broadcast_source)
{
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_param reconfig_param;
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_audio_codec_cfg codec_cfg;
int err;
/* Test NULL values */
printk("Test bt_bap_broadcast_source_reconfig with NULL source\n");
err = bt_bap_broadcast_source_reconfig(NULL, &preset_16_2_1.codec_cfg, &preset_16_2_1.qos);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL broadcast source did not fail\n");
return;
}
printk("Test bt_bap_broadcast_source_reconfig with NULL codec\n");
err = bt_bap_broadcast_source_reconfig(source, NULL, &preset_16_2_1.qos);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL codec did not fail\n");
return;
}
printk("Test bt_bap_broadcast_source_reconfig with NULL QoS\n");
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, NULL);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL QoS did not fail\n");
return;
}
/* Test invalid codec values */
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg =
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
codec_cfg.data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
printk("Test bt_bap_broadcast_source_reconfig with codec.data_len %zu\n",
codec_cfg.data_len);
err = bt_bap_broadcast_source_reconfig(source, &codec_cfg, &preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too high codec data len did not "
"fail\n");
FAIL("bt_bap_broadcast_source_reconfig with too high codec data len %zu did not "
"fail\n", codec_cfg.data_len);
return;
}
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg =
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
codec_cfg.meta_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE + 1;
printk("Test bt_bap_broadcast_source_reconfig with codec.meta_len %zu\n",
codec_cfg.meta_len);
err = bt_bap_broadcast_source_reconfig(source, &codec_cfg, &preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too high codec meta len did not "
"fail\n");
FAIL("bt_bap_broadcast_source_reconfig with too high codec meta len %u did not "
"fail\n", codec_cfg.meta_len);
return;
}
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE < 255) {
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg = memcpy(&codec_cfg, &preset_16_2_1.codec_cfg,
sizeof(preset_16_2_1.codec_cfg));
/* Set LTV data to invalid size */
codec_cfg.data_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE + 1;
printk("Test bt_bap_broadcast_source_reconfig with CC LTV size %u\n",
printk("Test bt_bap_broadcast_source_reconfig with CC LTV len %u\n",
codec_cfg.data_len);
err = bt_bap_broadcast_source_reconfig(source, &codec_cfg, &preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too large CC LTV did not "
"fail\n");
FAIL("bt_bap_broadcast_source_reconfig with CC LTV len %zu in "
"subgroup_param did not fail\n",
codec_cfg.data_len);
return;
}
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
}
if (CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE < 255) {
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
subgroup_param.codec_cfg = memcpy(&codec_cfg, &preset_16_2_1.codec_cfg,
sizeof(preset_16_2_1.codec_cfg));
/* Set LTV data to invalid size */
codec_cfg.meta_len = CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE + 1;
printk("Test bt_bap_broadcast_source_reconfig with meta LTV size %u\n",
codec_cfg.meta_len);
err = bt_bap_broadcast_source_reconfig(source, &codec_cfg, &preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too large meta LTV did not "
"fail\n");
FAIL("bt_bap_broadcast_source_reconfig with meta LTV size %zu in "
"subgroup_param did not fail\n",
codec_cfg.meta_len);
return;
}
}
}
memcpy(&codec_cfg, &preset_16_2_1.codec_cfg, sizeof(preset_16_2_1.codec_cfg));
static void test_broadcast_source_reconfig_inval_subgroup_param(
struct bt_bap_broadcast_source *broadcast_source)
{
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_param reconfig_param;
struct bt_bap_broadcast_source_stream_param stream_param;
int err;
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Set count to 0 */
subgroup_param.params_count = 0;
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with 0 stream_param count did not fail\n");
return;
}
memcpy(&qos, &preset_16_2_1.qos, sizeof(preset_16_2_1.qos));
/* Set count higher than max */
subgroup_param.params_count = CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT + 1;
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too high stream_param count did not "
"fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Set params to NULL */
subgroup_param.params = NULL;
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL stream_param did not fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
/* Set codec to NULL */
subgroup_param.codec_cfg = NULL;
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL codec did not fail\n");
return;
}
/* Invalid codec values */
test_broadcast_source_reconfig_inval_subgroup_codec_param(broadcast_source);
}
static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source *broadcast_source)
{
struct bt_bap_broadcast_source_stream_param stream_param;
struct bt_bap_broadcast_source_subgroup_param subgroup_param;
struct bt_bap_broadcast_source_param reconfig_param;
struct bt_audio_codec_qos qos;
int err;
/* Test NULL parameters */
printk("Test bt_bap_broadcast_source_reconfig with NULL broadcast source\n");
err = bt_bap_broadcast_source_reconfig(NULL, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL broadcast source did not fail\n");
return;
}
printk("Test bt_bap_broadcast_source_reconfig with NULL param\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, NULL);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL param did not fail\n");
return;
}
/* Test stream_param values */
test_broadcast_source_reconfig_inval_stream_param(broadcast_source);
/* Test invalid subgroup_param values*/
test_broadcast_source_reconfig_inval_subgroup_param(broadcast_source);
/* Invalid reconfig_param values */
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
reconfig_param.params_count = 0;
printk("Test bt_bap_broadcast_source_reconfig with 0 params_count\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with 0 params_count did not fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
reconfig_param.params = NULL;
printk("Test bt_bap_broadcast_source_reconfig with NULL params\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL params did not fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
reconfig_param.packing = 0x35;
printk("Test bt_bap_broadcast_source_reconfig with packing 0x%02X\n",
reconfig_param.packing);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with invalid packing did not fail\n");
return;
}
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
reconfig_param.qos = NULL;
printk("Test bt_bap_broadcast_source_reconfig with NULL qos\n");
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with NULL qos did not fail\n");
return;
}
/* Invalid QoS values */
broadcast_source_inval_reset_param(&reconfig_param, &subgroup_param, &stream_param);
reconfig_param.qos = memcpy(&qos, &preset_16_2_1.qos, sizeof(preset_16_2_1.qos));
qos.phy = BT_AUDIO_CODEC_QOS_CODED + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.phy %u\n", qos.phy);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.phy 0x%02X\n", qos.phy);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with invalid PHY did not fail\n");
return;
@ -853,8 +1070,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.framing = BT_AUDIO_CODEC_QOS_FRAMING_FRAMED + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.framing %u\n", qos.framing);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.framing 0x%02X\n", qos.framing);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with invalid framing did not fail\n");
return;
@ -864,8 +1081,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.rtn = BT_ISO_BROADCAST_RTN_MAX + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.rtn %u\n", qos.rtn);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.rtn 0x%02X\n", qos.rtn);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with invalid RTN did not fail\n");
return;
@ -875,8 +1092,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.sdu = BT_ISO_MAX_SDU + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.sdu %u\n", qos.sdu);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.sdu 0x%02X\n", qos.sdu);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with invalid SDU size did not fail\n");
return;
@ -886,8 +1103,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.latency = BT_ISO_LATENCY_MIN - 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.latency %u\n", qos.latency);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.latency 0x%02X\n", qos.latency);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too low latency did not fail\n");
return;
@ -897,8 +1114,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.latency = BT_ISO_LATENCY_MAX + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.latency %u\n", qos.latency);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.latency 0x%02X\n", qos.latency);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too high latency did not fail\n");
return;
@ -908,8 +1125,8 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.interval = BT_ISO_SDU_INTERVAL_MIN - 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.interval %u\n", qos.interval);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.interval 0x%02X\n", qos.interval);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too low interval did not fail\n");
return;
@ -919,21 +1136,58 @@ static void test_broadcast_source_reconfig_inval(struct bt_bap_broadcast_source
qos.interval = BT_ISO_SDU_INTERVAL_MAX + 1;
printk("Test bt_bap_broadcast_source_reconfig with qos.interval %u\n", qos.interval);
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg, &qos);
printk("Test bt_bap_broadcast_source_reconfig with qos.interval 0x%02X\n", qos.interval);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with too high interval did not fail\n");
return;
}
reconfig_param.params_count = CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT + 1;
printk("Test bt_bap_broadcast_source_reconfig with %zu subgroups\n",
reconfig_param.params_count);
err = bt_bap_broadcast_source_reconfig(broadcast_source, &reconfig_param);
if (err == 0) {
FAIL("bt_bap_broadcast_source_reconfig with %zu subgroups did not fail\n",
reconfig_param.params_count);
return;
}
}
static void test_broadcast_source_reconfig(struct bt_bap_broadcast_source *source)
{
uint8_t bis_codec_data[] = {
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CONFIG_LC3_FREQ,
BT_BYTES_LIST_LE16(BT_AUDIO_CODEC_CONFIG_LC3_FREQ_16KHZ)),
};
struct bt_bap_broadcast_source_stream_param
stream_params[ARRAY_SIZE(broadcast_source_streams)];
struct bt_bap_broadcast_source_subgroup_param
subgroup_params[CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT];
struct bt_bap_broadcast_source_param reconfig_param;
int err;
for (size_t i = 0; i < ARRAY_SIZE(stream_params); i++) {
stream_params[i].stream = &broadcast_source_streams[i];
stream_params[i].data_len = ARRAY_SIZE(bis_codec_data);
stream_params[i].data = bis_codec_data;
}
for (size_t i = 0U; i < ARRAY_SIZE(subgroup_params); i++) {
subgroup_params[i].params_count = 1U;
subgroup_params[i].params = &stream_params[i];
subgroup_params[i].codec_cfg = &preset_16_2_2.codec_cfg;
}
reconfig_param.params_count = ARRAY_SIZE(subgroup_params);
reconfig_param.params = subgroup_params;
reconfig_param.qos = &preset_16_2_2.qos;
reconfig_param.packing = BT_ISO_PACKING_SEQUENTIAL;
reconfig_param.encryption = false;
printk("Reconfiguring broadcast source\n");
err = bt_bap_broadcast_source_reconfig(source, &preset_16_2_1.codec_cfg,
&preset_16_2_1.qos);
err = bt_bap_broadcast_source_reconfig(source, &reconfig_param);
if (err != 0) {
FAIL("Unable to reconfigure broadcast source: %d\n", err);
return;
@ -1150,7 +1404,7 @@ static void test_main(void)
err = bt_bap_broadcast_source_update_metadata(source, new_metadata,
ARRAY_SIZE(new_metadata));
if (err != 0) {
FAIL("Failed to update metadata broadcast source: %d", err);
FAIL("Failed to update metadata broadcast source: %d\n", err);
return;
}