Skip to content

Commit a15cc2d

Browse files
Thalleykartben
authored andcommitted
tests: Bluetooth: BAP: Make RX checks less strict
Modify stream_rx.c so that the calls to FAIL are guarded by the newly added valid_rx_cnt. This helps prevent timing issues, especially with broadcast, where the first SDU(s) may be delayed from the application, and thus may be missed/contain errors. Now it will only treat missing or error SDUs as a FAIL if we have received a valid SDU. All fails, will still be logged. We now also log both valid and total count. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 3d9ac79 commit a15cc2d

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

tests/bsim/bluetooth/audio/src/bap_stream_rx.c

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,52 @@ void bap_stream_rx_recv_cb(struct bt_bap_stream *stream, const struct bt_iso_rec
3030
{
3131
struct audio_test_stream *test_stream = audio_test_stream_from_bap_stream(stream);
3232

33+
test_stream->rx_cnt++;
34+
if ((info->flags & BT_ISO_FLAGS_VALID) != 0) {
35+
if (memcmp(buf->data, mock_iso_data, buf->len) == 0) {
36+
test_stream->valid_rx_cnt++;
37+
38+
if (test_stream->valid_rx_cnt >= MIN_SEND_COUNT) {
39+
/* We set the flag is just one stream has received the expected */
40+
SET_FLAG(flag_audio_received);
41+
}
42+
} else {
43+
log_stream_rx(stream, info, buf);
44+
FAIL("Unexpected data received\n");
45+
}
46+
}
47+
3348
if ((test_stream->rx_cnt % 50U) == 0U) {
3449
log_stream_rx(stream, info, buf);
3550
}
3651

37-
test_stream->rx_cnt++;
38-
39-
if (test_stream->valid_rx_cnt > 0U && info->ts == test_stream->last_info.ts) {
52+
if (info->ts == test_stream->last_info.ts) {
4053
log_stream_rx(stream, info, buf);
41-
FAIL("Duplicated timestamp received: %u\n", test_stream->last_info.ts);
42-
return;
54+
if (test_stream->valid_rx_cnt > 1U) {
55+
FAIL("Duplicated timestamp received: %u\n", test_stream->last_info.ts);
56+
}
4357
}
4458

45-
if (test_stream->valid_rx_cnt > 0U && info->seq_num == test_stream->last_info.seq_num) {
59+
if (info->seq_num == test_stream->last_info.seq_num) {
4660
log_stream_rx(stream, info, buf);
47-
FAIL("Duplicated PSN received: %u\n", test_stream->last_info.seq_num);
48-
return;
61+
if (test_stream->valid_rx_cnt > 1U) {
62+
FAIL("Duplicated PSN received: %u\n", test_stream->last_info.seq_num);
63+
}
4964
}
5065

5166
if (info->flags & BT_ISO_FLAGS_ERROR) {
5267
/* Fail the test if we have not received what we expected */
53-
if (!TEST_FLAG(flag_audio_received)) {
54-
log_stream_rx(stream, info, buf);
55-
if (test_stream->valid_rx_cnt > 0) {
56-
FAIL("ISO receive error\n");
57-
}
68+
log_stream_rx(stream, info, buf);
69+
if (test_stream->valid_rx_cnt > 1U && !TEST_FLAG(flag_audio_received)) {
70+
FAIL("ISO receive error\n");
5871
}
59-
60-
return;
6172
}
6273

6374
if (info->flags & BT_ISO_FLAGS_LOST) {
6475
log_stream_rx(stream, info, buf);
65-
if (test_stream->valid_rx_cnt > 0) {
76+
if (test_stream->valid_rx_cnt > 1U) {
6677
FAIL("ISO receive lost\n");
6778
}
68-
return;
69-
}
70-
71-
if (info->flags & BT_ISO_FLAGS_VALID) {
72-
if (memcmp(buf->data, mock_iso_data, buf->len) == 0) {
73-
test_stream->valid_rx_cnt++;
74-
75-
if (test_stream->rx_cnt >= MIN_SEND_COUNT) {
76-
/* We set the flag is just one stream has received the expected */
77-
SET_FLAG(flag_audio_received);
78-
}
79-
} else {
80-
log_stream_rx(stream, info, buf);
81-
FAIL("Unexpected data received\n");
82-
}
8379
}
8480
}
8581

0 commit comments

Comments
 (0)