Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Audio: Add tests for the CAP cancel command #82315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kruithofa
Copy link
Collaborator

@kruithofa kruithofa commented Nov 29, 2024

This adds unittests and babblesim tests for the CAP cancel command

Fixes #71424

This adds unittests and babblesim tests for the CAP cancel command

Signed-off-by: Andries Kruithof <[email protected]>

void set_skip_add_src(int nr_to_skip);

LOG_MODULE_REGISTER(bt_cancel, CONFIG_BT_CAP_COMMANDER_LOG_LEVEL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are registering a log here? Seems unused

Comment on lines +99 to +102
for (size_t i = 0; i < ARRAY_SIZE(fixture->conns); i++) {
err = bt_cap_commander_discover(&fixture->conns[i]);
zassert_equal(0, err, "Unexpected return value %d", err);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cap_commander_test_cancel_fixture_init also does discovery - Should remove one of them

Comment on lines +151 to +152
err = bt_cap_commander_broadcast_reception_start(&fixture->start_param);
zassert_equal(0, err, "Could not start CAP procedure: %d", err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there value in testing the cancel for the other CAP Commander procedures too, and not just the broadcast reception start?

Comment on lines +96 to +100
if (add_src_skip != 0) {
add_src_skip--;

return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand this feature correctly:

We can set a value, add_src_skip, that effectively delays the response from the server indefinitely, thus causing the procedure to never finish on it's own, which allows us to cancel it?

If so, then it's a creative solution. Could this have been done with the mocked k_work implementation we have?

Two comments about the design of this:

  1. In some ways, it's a bit odd that we skip the first N callbacks, and not the last N callbacks, but the result will be the same
  2. This is not a very scalable solution if we want to do the commander cancel test for the remaining CAP commander procedures. On the top of my head, I don't have a general solution for this though.

Comment on lines +15 to +17
static int add_src_skip;

void set_skip_add_src(int setting)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static int add_src_skip;
void set_skip_add_src(int setting)
static unsigned int add_src_skip;
void set_skip_add_src(unsigned int setting)

Comment on lines +850 to +856
int new_volume;

UNSET_FLAG(flag_volume_changed);
new_volume = init_change_volume();
WAIT_FOR_FLAG(flag_volume_changed);
printk("Volume changed to %u\n", param.volume);

printk("Volume changed to %u\n", new_volume);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of adding the return value? On error FAIL is already called

Comment on lines +29 to +31
#Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
# -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=cap_acceptor_broadcast_reception \
# -RealEncryption=1 -rs=69 -D=${NR_OF_DEVICES}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
# -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=cap_acceptor_broadcast_reception \
# -RealEncryption=1 -rs=69 -D=${NR_OF_DEVICES}

Comment on lines +32 to +43





# Simulation time should be larger than the WAIT_TIME in common.h
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
-D=${NR_OF_DEVICES} -sim_length=60e6 $@



wait_for_background_jobs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Simulation time should be larger than the WAIT_TIME in common.h
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
-D=${NR_OF_DEVICES} -sim_length=60e6 $@
wait_for_background_jobs
# Simulation time should be larger than the WAIT_TIME in common.h
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
-D=${NR_OF_DEVICES} -sim_length=60e6 $@
wait_for_background_jobs


cd ${BSIM_OUT_PATH}/bin

printf "\n\n======== Running CAP commander broadcast reception start and stop test =========\n\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf "\n\n======== Running CAP commander broadcast reception start and stop test =========\n\n"
printf "\n\n======== Running CAP commander cancel test =========\n\n"

#
# SPDX-License-Identifier: Apache-2.0

SIMULATION_ID="cap_broadcast_reception"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SIMULATION_ID="cap_broadcast_reception"
SIMULATION_ID="cap_commander_cancel"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

LE Audio: Add BSIM and unit test for bt_cap_commander_cancel
3 participants