Skip to content

Commit e85a0bc

Browse files
MariuszSkamracarlescufi
authored andcommitted
tests: Bluetooth: ascs: Extend mock_bt_iso_disconnected with error param
This extends mock_bt_iso_disconnected function parameters with error code that can provide the HCI error code that is the reason of CIS disconnection. Signed-off-by: Mariusz Skamra <[email protected]>
1 parent 2f18ee0 commit e85a0bc

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ ZTEST_F(ascs_test_suite, test_release_ase_on_acl_disconnection_client_terminates
244244
!IS_ENABLED(CONFIG_BT_ASCS_ASE_SNK));
245245

246246
/* Mock ACL disconnection */
247-
mock_bt_conn_disconnected(conn, BT_HCI_ERR_CONN_TIMEOUT);
247+
mock_bt_conn_disconnected(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
248248

249249
/* Mock CIS disconnection */
250-
mock_bt_iso_disconnect(chan);
250+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
251251

252252
/* Expected to notify the upper layers */
253253
expect_bt_bap_unicast_server_cb_release_called_once(stream);
@@ -342,10 +342,10 @@ ZTEST_F(ascs_test_suite, test_release_stream_pair_on_acl_disconnection_client_te
342342
test_mocks_reset();
343343

344344
/* Mock ACL disconnection */
345-
mock_bt_conn_disconnected(conn, BT_HCI_ERR_CONN_TIMEOUT);
345+
mock_bt_conn_disconnected(conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
346346

347347
/* Mock CIS disconnection */
348-
mock_bt_iso_disconnect(chan);
348+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
349349

350350
/* Expected to notify the upper layers */
351351
const struct bt_bap_stream *streams[2] = { &snk_stream, &src_stream };

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ZTEST_F(test_sink_ase_state_transition, test_client_streaming_to_releasing)
276276
test_ase_control_client_release(conn, ase_id);
277277

278278
/* Client disconnects the ISO */
279-
mock_bt_iso_disconnect(chan);
279+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
280280

281281
/* Verification */
282282
expect_bt_bap_unicast_server_cb_release_called_once(stream);
@@ -566,7 +566,7 @@ ZTEST_F(test_sink_ase_state_transition, test_server_streaming_to_releasing)
566566
zassert_false(err < 0, "bt_bap_stream_release returned err %d", err);
567567

568568
/* Client disconnects the ISO */
569-
mock_bt_iso_disconnect(chan);
569+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
570570

571571
/* Verification */
572572
expect_bt_bap_unicast_server_cb_release_called_once(stream);
@@ -814,8 +814,9 @@ ZTEST_F(test_source_ase_state_transition, test_client_streaming_to_releasing)
814814
test_preamble_state_streaming(conn, ase_id, stream, &chan, true);
815815

816816
test_ase_control_client_release(conn, ase_id);
817+
817818
/* Client disconnects the ISO */
818-
mock_bt_iso_disconnect(chan);
819+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
819820

820821
/* Verification */
821822
expect_bt_bap_unicast_server_cb_release_called_once(stream);
@@ -1125,7 +1126,7 @@ ZTEST_F(test_source_ase_state_transition, test_server_streaming_to_releasing)
11251126
zassert_false(err < 0, "bt_bap_stream_release returned err %d", err);
11261127

11271128
/* Client disconnects the ISO */
1128-
mock_bt_iso_disconnect(chan);
1129+
mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
11291130

11301131
/* Verification */
11311132
expect_bt_bap_unicast_server_cb_release_called_once(stream);

tests/bluetooth/audio/mocks/include/iso.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void mock_bt_iso_init(void);
1414
void mock_bt_iso_cleanup(void);
1515
int mock_bt_iso_accept(struct bt_conn *conn, uint8_t cig_id, uint8_t cis_id,
1616
struct bt_iso_chan **chan);
17-
int mock_bt_iso_disconnect(struct bt_iso_chan *chan);
17+
int mock_bt_iso_disconnected(struct bt_iso_chan *chan, uint8_t err);
1818

1919
DECLARE_FAKE_VALUE_FUNC(int, bt_iso_chan_send, struct bt_iso_chan *, struct net_buf *, uint16_t,
2020
uint32_t);

tests/bluetooth/audio/mocks/src/iso.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ int bt_iso_server_unregister(struct bt_iso_server *server)
4646

4747
int bt_iso_chan_disconnect(struct bt_iso_chan *chan)
4848
{
49-
chan->state = BT_ISO_STATE_DISCONNECTED;
50-
chan->ops->disconnected(chan, 0x13);
51-
free(chan->iso);
52-
53-
return 0;
49+
return mock_bt_iso_disconnected(chan, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
5450
}
5551

5652
void mock_bt_iso_init(void)
@@ -91,7 +87,12 @@ int mock_bt_iso_accept(struct bt_conn *conn, uint8_t cig_id, uint8_t cis_id,
9187
return 0;
9288
}
9389

94-
int mock_bt_iso_disconnect(struct bt_iso_chan *chan)
90+
int mock_bt_iso_disconnected(struct bt_iso_chan *chan, uint8_t err)
9591
{
96-
return bt_iso_chan_disconnect(chan);
92+
chan->state = BT_ISO_STATE_DISCONNECTED;
93+
chan->ops->disconnected(chan, err);
94+
free(chan->iso);
95+
chan->iso = NULL;
96+
97+
return 0;
9798
}

0 commit comments

Comments
 (0)