Skip to content

tests: Bluetooth: Tester: VCP BSIM test #86664

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MAINTAINERS.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like the change to this file does not apply when assigning reviewers and labels

Copy link
Member

Choose a reason for hiding this comment

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

Correct. Only the maintainers file owner itself is notified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's pretty interesting, because that means there's a chicken-and-egg situation here, right?

We cannot files to MAINTAINERS.yml before they exist, and the file isn't applied when added together :)

It's not a big issue, but was a bit surprising as generally changes to files in a PR is applied to CI

Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ Bluetooth Host:
- tests/bsim/bluetooth/hci_uart/
- tests/bsim/bluetooth/ll/
- tests/bsim/bluetooth/mesh/
- tests/bsim/bluetooth/tester/src/audio/
labels:
- "area: Bluetooth Host"
- "area: Bluetooth"
Expand Down Expand Up @@ -534,6 +535,7 @@ Bluetooth Audio:
- tests/bluetooth/audio/
- tests/bsim/bluetooth/audio/
- tests/bsim/bluetooth/audio_samples/
- tests/bsim/bluetooth/tester/src/audio/
- tests/bluetooth/shell/audio.conf
- tests/bluetooth/tester/overlay-le-audio.conf
- tests/bluetooth/tester/overlay-bt_ll_sw_split.conf
Expand Down
11 changes: 11 additions & 0 deletions tests/bluetooth/tester/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ tests:
tags: bluetooth
harness: bluetooth
sysbuild: true
bluetooth.general.tester_le_audio_bsim:
build_only: true
platform_allow:
- nrf52_bsim/native
- nrf5340bsim/nrf5340/cpuapp
extra_args:
- EXTRA_CONF_FILE="overlay-le-audio.conf"
harness: bsim
harness_config:
bsim_exe_name: tests_bluetooth_tester_le_audio_prj_conf
sysbuild: true
bluetooth.general.tester_mesh:
build_only: true
platform_allow:
Expand Down
2 changes: 2 additions & 0 deletions tests/bsim/bluetooth/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ zephyr_include_directories(
target_sources(app PRIVATE
src/bsim_btp.c
src/test_main.c
src/audio/vcp_central.c
src/audio/vcp_peripheral.c
src/host/gap_central.c
src/host/gap_peripheral.c
)
93 changes: 93 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/vcp_central.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_vcp_central, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_vcp_central(void)
{
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_t remote_addr;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_VCP);
bsim_btp_core_register(BTP_SERVICE_ID_VOCS);
bsim_btp_core_register(BTP_SERVICE_ID_AICS);

bsim_btp_gap_start_discovery(BTP_GAP_DISCOVERY_FLAG_LE);
bsim_btp_wait_for_gap_device_found(&remote_addr);
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
LOG_INF("Found remote device %s", addr_str);

bsim_btp_gap_stop_discovery();
bsim_btp_gap_connect(&remote_addr, BTP_GAP_ADDR_TYPE_IDENTITY);
bsim_btp_wait_for_gap_device_connected(NULL);
LOG_INF("Device %s connected", addr_str);

bsim_btp_gap_pair(&remote_addr);
bsim_btp_wait_for_gap_sec_level_changed(NULL, NULL);

bsim_btp_vcp_discover(&remote_addr);
bsim_btp_wait_for_vcp_discovered(NULL);

const uint8_t new_vol = 123;
uint8_t ev_vol;

bsim_btp_vcp_ctlr_set_vol(&remote_addr, new_vol);
bsim_btp_wait_for_vcp_state(NULL, &ev_vol);
TEST_ASSERT(ev_vol == new_vol, "%u != %u", ev_vol, new_vol);

const int16_t new_offset = -5;
int16_t ev_offset;

bsim_btp_vocs_state_set(&remote_addr, new_offset);
bsim_btp_wait_for_vocs_state(NULL, &ev_offset);
TEST_ASSERT(ev_offset == new_offset, "%d != %d", ev_offset, new_offset);

const int8_t new_gain = 5;
int8_t ev_gain;

bsim_btp_aics_set_gain(&remote_addr, new_gain);
bsim_btp_wait_for_aics_state(NULL, &ev_gain);
TEST_ASSERT(ev_gain == new_gain, "%d != %d", ev_gain, new_gain);

bsim_btp_gap_disconnect(&remote_addr);
bsim_btp_wait_for_gap_device_disconnected(NULL);
LOG_INF("Device %s disconnected", addr_str);

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "vcp_central",
.test_descr = "Smoketest for the VCP central BT Tester behavior",
.test_main_f = test_vcp_central,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_vcp_central_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
60 changes: 60 additions & 0 deletions tests/bsim/bluetooth/tester/src/audio/vcp_peripheral.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdint.h>

#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util_macro.h>

#include "babblekit/testcase.h"
#include "bstests.h"

#include "btp/btp.h"
#include "bsim_btp.h"

LOG_MODULE_REGISTER(bsim_vcp_peripheral, CONFIG_BSIM_BTTESTER_LOG_LEVEL);

static void test_vcp_peripheral(void)
{
char addr_str[BT_ADDR_LE_STR_LEN];
bt_addr_le_t remote_addr;

bsim_btp_uart_init();

bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL);

bsim_btp_core_register(BTP_SERVICE_ID_GAP);
bsim_btp_core_register(BTP_SERVICE_ID_VCS);
bsim_btp_core_register(BTP_SERVICE_ID_VOCS);
bsim_btp_core_register(BTP_SERVICE_ID_AICS);

bsim_btp_gap_set_discoverable(BTP_GAP_GENERAL_DISCOVERABLE);
bsim_btp_gap_start_advertising(0U, 0U, NULL, BT_HCI_OWN_ADDR_PUBLIC);
bsim_btp_wait_for_gap_device_connected(&remote_addr);
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str));
LOG_INF("Device %s connected", addr_str);
bsim_btp_wait_for_gap_device_disconnected(NULL);
LOG_INF("Device %s disconnected", addr_str);

TEST_PASS("PASSED\n");
}

static const struct bst_test_instance test_sample[] = {
{
.test_id = "vcp_peripheral",
.test_descr = "Smoketest for the VCP peripheral BT Tester behavior",
.test_main_f = test_vcp_peripheral,
},
BSTEST_END_MARKER,
};

struct bst_test_list *test_vcp_peripheral_install(struct bst_test_list *tests)
{
return bst_add_tests(tests, test_sample);
}
2 changes: 2 additions & 0 deletions tests/bsim/bluetooth/tester/src/bsim_btp.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ static bool is_valid_gap_packet_len(const struct btp_hdr *hdr, struct net_buf_si
} else {
return false;
}
case BTP_GAP_EV_ENCRYPTION_CHANGE:
return buf_simple->len == sizeof(struct btp_gap_encryption_change_ev);
default:
LOG_ERR("Unhandled opcode 0x%02X", hdr->opcode);
return false;
Expand Down
Loading