Skip to content

Commit

Permalink
tests: Bluetooth: BAP: Improve validation of broadcast source reconfig
Browse files Browse the repository at this point in the history
Add verification of all stream's SDU, RTN and PHY rather than
just the first.

Also add another test case where only a subset of streams are being
reconfigured, but where the above values shall be updated for
all streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley authored and jhedberg committed Oct 12, 2023
1 parent de67ec9 commit b63d8ff
Showing 1 changed file with 93 additions and 12 deletions.
105 changes: 93 additions & 12 deletions tests/bluetooth/audio/bap_broadcast_source/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ ZTEST_SUITE(bap_broadcast_source_test_suite, NULL, bap_broadcast_source_test_sui
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_delete)
{
struct bt_bap_broadcast_source_param *create_param = fixture->param;
struct bt_bap_stream *stream = create_param->params[0].params[0].stream;
int err;

printk("Creating broadcast source with %zu subgroups with %zu streams\n",
Expand All @@ -185,9 +184,19 @@ ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_create_delete)
err = bt_bap_broadcast_source_create(create_param, &fixture->source);
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);

zassert_equal(create_param->qos->sdu, stream->qos->sdu, "Unexpected stream SDU");
zassert_equal(create_param->qos->rtn, stream->qos->rtn, "Unexpected stream RTN");
zassert_equal(create_param->qos->phy, stream->qos->phy, "Unexpected stream PHY");
for (size_t i = 0u; i < create_param->params_count; i++) {
for (size_t j = 0u; j < create_param->params[i].params_count; j++) {
const struct bt_bap_stream *stream =
create_param->params[i].params[j].stream;

zassert_equal(create_param->qos->sdu, stream->qos->sdu,
"Unexpected stream SDU");
zassert_equal(create_param->qos->rtn, stream->qos->rtn,
"Unexpected stream RTN");
zassert_equal(create_param->qos->phy, stream->qos->phy,
"Unexpected stream PHY");
}
}

err = bt_bap_broadcast_source_delete(fixture->source);
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
Expand Down Expand Up @@ -520,32 +529,104 @@ ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_start_inval_doubl
zassert_not_equal(0, err, "Did not fail with starting already started source");
}

ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure)
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_single_subgroup)
{
struct bt_bap_broadcast_source_param *reconf_param = fixture->param;
struct bt_bap_stream *stream = reconf_param->params[0].params[0].stream;
const size_t subgroup_cnt = reconf_param->params_count;
int err;

printk("Creating broadcast source with %zu subgroups with %zu streams\n",
reconf_param->params_count, fixture->stream_cnt);

err = bt_bap_broadcast_source_create(reconf_param, &fixture->source);
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);

for (size_t i = 0u; i < reconf_param->params_count; i++) {
for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
const struct bt_bap_stream *stream =
reconf_param->params[i].params[j].stream;

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
"Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
"Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy,
"Unexpected stream PHY");
}
}

reconf_param->params_count = 1U;
reconf_param->qos->sdu = 100U;
reconf_param->qos->rtn = 3U;
reconf_param->qos->phy = 1U;

err = bt_bap_broadcast_source_reconfig(fixture->source, reconf_param);
zassert_equal(0, err, "Unable to reconfigure broadcast source: err %d", err);

for (size_t i = 0u; i < subgroup_cnt; i++) {
for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
const struct bt_bap_stream *stream =
reconf_param->params[i].params[j].stream;

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
"Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
"Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy,
"Unexpected stream PHY");
}
}

err = bt_bap_broadcast_source_delete(fixture->source);
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
fixture->source = NULL;
}

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu, "Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn, "Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy, "Unexpected stream PHY");
ZTEST_F(bap_broadcast_source_test_suite, test_broadcast_source_reconfigure_all)
{
struct bt_bap_broadcast_source_param *reconf_param = fixture->param;
int err;

printk("Creating broadcast source with %zu subgroups with %zu streams\n",
reconf_param->params_count, fixture->stream_cnt);

err = bt_bap_broadcast_source_create(reconf_param, &fixture->source);
zassert_equal(0, err, "Unable to create broadcast source: err %d", err);

for (size_t i = 0u; i < reconf_param->params_count; i++) {
for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
const struct bt_bap_stream *stream =
reconf_param->params[i].params[j].stream;

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
"Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
"Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy,
"Unexpected stream PHY");
}
}

reconf_param->qos->sdu = 100U;
reconf_param->qos->rtn = 3U;
reconf_param->qos->phy = 1U;

err = bt_bap_broadcast_source_reconfig(fixture->source, reconf_param);
zassert_equal(0, err, "Unable to reconfigure broadcast source: err %d", err);

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu, "Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn, "Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy, "Unexpected stream PHY");
for (size_t i = 0u; i < reconf_param->params_count; i++) {
for (size_t j = 0u; j < reconf_param->params[i].params_count; j++) {
const struct bt_bap_stream *stream =
reconf_param->params[i].params[j].stream;

zassert_equal(reconf_param->qos->sdu, stream->qos->sdu,
"Unexpected stream SDU");
zassert_equal(reconf_param->qos->rtn, stream->qos->rtn,
"Unexpected stream RTN");
zassert_equal(reconf_param->qos->phy, stream->qos->phy,
"Unexpected stream PHY");
}
}

err = bt_bap_broadcast_source_delete(fixture->source);
zassert_equal(0, err, "Unable to delete broadcast source: err %d", err);
Expand Down

0 comments on commit b63d8ff

Please sign in to comment.