Skip to content

Commit 91ad386

Browse files
MariuszSkamracarlescufi
authored andcommitted
tests: Bluetooth: ascs: Add ISO Data PDU recv tests
This adds tests for receiving ISO Data PDU. * test_recv_in_streaming_state - test whether received ISO Data PDU is sent to upper layers. * test_recv_in_enabling_state - test whether received ISO Data PDu is dropped because upper layer is not ready to receive the data yet. Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 9694e85 commit 91ad386

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

tests/bluetooth/audio/ascs/src/main.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,61 @@ ZTEST_F(ascs_test_suite, test_release_stream_pair_on_acl_disconnection_server_te
421421

422422
bt_bap_unicast_server_unregister_cb(&mock_bap_unicast_server_cb);
423423
}
424+
425+
ZTEST_F(ascs_test_suite, test_recv_in_streaming_state)
426+
{
427+
struct bt_bap_stream *stream = &fixture->stream;
428+
struct bt_conn *conn = &fixture->conn;
429+
uint8_t ase_id = fixture->ase_snk.id;
430+
struct bt_iso_recv_info info = {
431+
.seq_num = 1,
432+
.flags = BT_ISO_FLAGS_VALID,
433+
};
434+
struct bt_iso_chan *chan;
435+
struct net_buf buf;
436+
437+
Z_TEST_SKIP_IFNDEF(CONFIG_BT_ASCS_ASE_SNK);
438+
439+
bt_bap_unicast_server_register_cb(&mock_bap_unicast_server_cb);
440+
441+
test_preamble_state_streaming(conn, ase_id, stream, &chan, false);
442+
443+
chan->ops->recv(chan, &info, &buf);
444+
445+
/* Verification */
446+
expect_bt_bap_stream_ops_recv_called_once(stream, &info, &buf);
447+
448+
bt_bap_unicast_server_unregister_cb(&mock_bap_unicast_server_cb);
449+
}
450+
451+
ZTEST_F(ascs_test_suite, test_recv_in_enabling_state)
452+
{
453+
struct bt_bap_stream *stream = &fixture->stream;
454+
struct bt_conn *conn = &fixture->conn;
455+
uint8_t ase_id = fixture->ase_snk.id;
456+
struct bt_iso_recv_info info = {
457+
.seq_num = 1,
458+
.flags = BT_ISO_FLAGS_VALID,
459+
};
460+
struct bt_iso_chan *chan;
461+
struct net_buf buf;
462+
int err;
463+
464+
Z_TEST_SKIP_IFNDEF(CONFIG_BT_ASCS_ASE_SNK);
465+
466+
bt_bap_unicast_server_register_cb(&mock_bap_unicast_server_cb);
467+
468+
test_preamble_state_enabling(conn, ase_id, stream);
469+
470+
err = mock_bt_iso_accept(conn, 0x01, 0x01, &chan);
471+
zassert_equal(0, err, "Failed to connect iso: err %d", err);
472+
473+
test_mocks_reset();
474+
475+
chan->ops->recv(chan, &info, &buf);
476+
477+
/* Verification */
478+
expect_bt_bap_stream_ops_recv_not_called();
479+
480+
bt_bap_unicast_server_unregister_cb(&mock_bap_unicast_server_cb);
481+
}

tests/bluetooth/audio/mocks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_library(mocks STATIC
1616
src/iso.c
1717
src/kernel.c
1818
src/mem_slab.c
19+
src/net_buf.c
1920
src/pacs.c
2021
)
2122

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2023 Codecoup
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <kernel.h>
8+
#include <zephyr/net/buf.h>
9+
10+
void net_buf_unref(struct net_buf *buf)
11+
{
12+
13+
}

0 commit comments

Comments
 (0)