Skip to content

tests: bsim: bap: fix race on ISO lost after audio received#36

Draft
cvinayak with Copilot wants to merge 2 commits into
mainfrom
copilot/bluetooth-bap-race-condition-fix
Draft

tests: bsim: bap: fix race on ISO lost after audio received#36
cvinayak with Copilot wants to merge 2 commits into
mainfrom
copilot/bluetooth-bap-race-condition-fix

Conversation

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown

Late BT_ISO_FLAGS_LOST packets can arrive after the BAP Unicast Client sends a release but before the ASE state-change notification is received — the server has stopped streaming while the CIS is still active. Since valid_rx_cnt > 1U at end-of-test, this spuriously fails the RX callback in bap_stream_rx.c.

Change

  • Guard the BT_ISO_FLAGS_LOST failure with !TEST_FLAG(flag_audio_received), mirroring the pre-existing pattern used one branch above for BT_ISO_FLAGS_ERROR. Once the minimum expected SDUs have been received, a late lost indication is expected and no longer fails the test.
if (info->flags & BT_ISO_FLAGS_LOST) {
    log_stream_err(test_stream, info, buf);

    if (test_stream->valid_rx_cnt > 1U &&
        !TEST_FLAG(test_stream->flag_audio_received)) {
        FAIL("ISO receive lost\n");
    }
}

When the BAP Unicast Client acts as an audio sink and the client sends
a release command, the server stops streaming but the CIS may still be
active. If the ASE state-change notification does not reach the client
before the next (now empty) HCI ISO packet arrives, that packet is
delivered with BT_ISO_FLAGS_LOST. Because the test is near completion,
valid_rx_cnt > 1U and the FAIL was triggered even though the test had
already effectively succeeded.

Guard the LOST failure with !TEST_FLAG(flag_audio_received), matching
the existing pattern already used for BT_ISO_FLAGS_ERROR just above.
Once the minimum expected number of valid SDUs has been received, a
late lost indication caused by the release/notification race is
expected and should not fail the test.

Fixes zephyrproject-rtos#112496
Copilot AI changed the title [WIP] Fix race condition in BSIM RX test for BAP tests: bsim: bap: fix race on ISO lost after audio received Jul 5, 2026
Copilot AI requested a review from cvinayak July 5, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bluetooth: BAP: Race condition in BSIM RX test

2 participants