Skip to content

Commit

Permalink
tests: Bluetooth: Split cap initiator unicast inval test to new func
Browse files Browse the repository at this point in the history
Add a new test function to test invalid behavior to keep the
valid behavior test cleaner.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley committed Jun 8, 2023
1 parent 170bcff commit 3c74174
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
44 changes: 39 additions & 5 deletions tests/bsim/bluetooth/audio/src/cap_initiator_unicast_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ static void test_main_cap_initiator_unicast(void)

WAIT_FOR_FLAG(flag_mtu_exchanged);

discover_cas_inval();
discover_cas();

discover_sink();
Expand All @@ -634,31 +633,66 @@ static void test_main_cap_initiator_unicast(void)
unicast_group_create(&unicast_group);

for (size_t j = 0U; j < iterations; j++) {
unicast_audio_start_inval(unicast_group);
unicast_audio_start(unicast_group);

unicast_audio_update_inval();
unicast_audio_update();

unicast_audio_stop_inval();
unicast_audio_stop(unicast_group);
}

unicast_group_delete_inval();
unicast_group_delete(unicast_group);
unicast_group = NULL;
}

PASS("CAP initiator unicast passed\n");
}

static void test_main_cap_initiator_unicast_inval(void)
{
struct bt_bap_unicast_group *unicast_group;

init();

scan_and_connect();

WAIT_FOR_FLAG(flag_mtu_exchanged);

discover_cas_inval();
discover_cas();

discover_sink();

unicast_group_create(&unicast_group);

unicast_audio_start_inval(unicast_group);
unicast_audio_start(unicast_group);

unicast_audio_update_inval();
unicast_audio_update();

unicast_audio_stop_inval();
unicast_audio_stop(unicast_group);

unicast_group_delete_inval();
unicast_group_delete(unicast_group);
unicast_group = NULL;

PASS("CAP initiator unicast inval passed\n");
}

static const struct bst_test_instance test_cap_initiator_unicast[] = {
{
.test_id = "cap_initiator_unicast",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_main_cap_initiator_unicast,
},
{
.test_id = "cap_initiator_unicast_inval",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_main_cap_initiator_unicast_inval,
},
BSTEST_END_MARKER,
};

Expand Down
2 changes: 2 additions & 0 deletions tests/bsim/bluetooth/audio/test_scripts/_cap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

dir_path=$(dirname "$0")

$dir_path/cap_unicast_inval.sh

$dir_path/cap_unicast.sh

$dir_path/cap_broadcast.sh
27 changes: 27 additions & 0 deletions tests/bsim/bluetooth/audio/test_scripts/cap_unicast_inval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0

SIMULATION_ID="cap_unicast_inval"
VERBOSITY_LEVEL=2
EXECUTE_TIMEOUT=20

source ${ZEPHYR_BASE}/tests/bsim/sh_common.source

cd ${BSIM_OUT_PATH}/bin

printf "\n\n======== Running CAP unicast test =========\n\n"

Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=cap_initiator_unicast_inval -rs=46

Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=cap_acceptor_unicast -rs=23

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

wait_for_background_jobs

0 comments on commit 3c74174

Please sign in to comment.