Skip to content

tests: Bluetooth: Add BT Tester GAP smoke test #86146

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

Merged
merged 1 commit into from
Apr 8, 2025
Merged
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
1 change: 1 addition & 0 deletions tests/bluetooth/tester/Kconfig.sysbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config NET_CORE_BOARD
string
default "nrf5340dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340dk"
default "nrf5340_audio_dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340_audio_dk"
default "nrf5340bsim/nrf5340/cpunet" if $(BOARD_TARGET_STRING) = "NRF5340BSIM_NRF5340_CPUAPP"

config NET_CORE_IMAGE_HCI_IPC
bool "HCI IPC image on network core"
Expand Down
15 changes: 15 additions & 0 deletions tests/bluetooth/tester/boards/nrf52_bsim.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CONFIG_TEST enforces minimal logging, which we don't want
CONFIG_TEST=n

CONFIG_ASSERT=y
CONFIG_THREAD_NAME=y

CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=y
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y

CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_BTTESTER_LOG_LEVEL_DBG=y

CONFIG_UART_PIPE=n
5 changes: 5 additions & 0 deletions tests/bluetooth/tester/boards/nrf52_bsim.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: Apache-2.0 */

&uart0 {
hw-flow-control;
};
18 changes: 18 additions & 0 deletions tests/bluetooth/tester/boards/nrf5340bsim_nrf5340_cpuapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# CONFIG_TEST enforces minimal logging, which we don't want
CONFIG_TEST=n

CONFIG_ASSERT=y
CONFIG_THREAD_NAME=y

CONFIG_LOG=y
CONFIG_LOG_BACKEND_SHOW_COLOR=y
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y

CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_BTTESTER_LOG_LEVEL_DBG=y

CONFIG_UART_PIPE=n
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_SERIAL=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* SPDX-License-Identifier: Apache-2.0 */

&uart0 {
compatible = "nordic,nrf-uarte";
hw-flow-control;
};
7 changes: 7 additions & 0 deletions tests/bluetooth/tester/src/btp/btp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef TESTS_BLUETOOTH_TESTER_SRC_BTP_
#define TESTS_BLUETOOTH_TESTER_SRC_BTP_

#include <zephyr/sys/util.h>
#include <zephyr/bluetooth/addr.h>

Expand Down Expand Up @@ -87,6 +90,8 @@

#define BTP_STATUS_VAL(err) (err) ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS

#define BTP_EVENT_OPCODE 0x80
Copy link
Contributor Author

Choose a reason for hiding this comment

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


/* TODO indicate delay response, should be removed when all commands are
* converted to cmd+status+ev pattern
*/
Expand All @@ -104,3 +109,5 @@ struct btp_hdr {
struct btp_status {
uint8_t code;
} __packed;

#endif /* TESTS_BLUETOOTH_TESTER_SRC_BTP_ */
20 changes: 20 additions & 0 deletions tests/bluetooth/tester/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
common:
build_only: true
tags: bluetooth

tests:
bluetooth.general.tester:
build_only: true
Expand All @@ -7,6 +11,12 @@ tests:
- nrf52840dk/nrf52840
tags: bluetooth
harness: bluetooth
bluetooth.general.tester_bsim:
platform_allow:
- nrf52_bsim/native
harness: bsim
harness_config:
bsim_exe_name: tests_bluetooth_tester_prj_conf
bluetooth.general.tester.nxp:
# Disabling monolithic since CI environment doesn't use blobs
build_only: true
Expand All @@ -30,6 +40,16 @@ tests:
- EXTRA_CONF_FILE="hci_ipc.conf"
tags: bluetooth
sysbuild: true
bluetooth.general.tester_hci_ipc_bsim:
platform_allow:
- nrf5340bsim/nrf5340/cpuapp
harness: bsim
harness_config:
bsim_exe_name: tests_bluetooth_tester_prj_conf
extra_args:
# Build config used by AutoPTS for nRF53
- EXTRA_CONF_FILE="hci_ipc.conf"
sysbuild: true
bluetooth.general.tester_le_audio:
build_only: true
platform_allow:
Expand Down
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpuapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export BOARD="${BOARD:-nrf5340bsim/nrf5340/cpuapp}"
source ${ZEPHYR_BASE}/tests/bsim/compile.source

${ZEPHYR_BASE}/tests/bsim/bluetooth/host/compile.sh
${ZEPHYR_BASE}/tests/bsim/bluetooth/tester/compile.sh

app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_privacy.conf sysbuild=1 compile
app=tests/bsim/bluetooth/ll/throughput sysbuild=1 compile
Expand Down
1 change: 1 addition & 0 deletions tests/bsim/bluetooth/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ ${ZEPHYR_BASE}/tests/bsim/bluetooth/samples/compile.sh
if [ ${BOARD} == "nrf52_bsim/native" ]; then
${ZEPHYR_BASE}/tests/bsim/bluetooth/hci_uart/compile.sh
fi
${ZEPHYR_BASE}/tests/bsim/bluetooth/tester/compile.sh

wait_for_background_jobs
29 changes: 29 additions & 0 deletions tests/bsim/bluetooth/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(tester_bsim)

# This contains babblesim-specific helpers, e.g. device synchronization.
add_subdirectory(${ZEPHYR_BASE}/tests/bsim/babblekit babblekit)
target_link_libraries(app PRIVATE babblekit)

zephyr_include_directories(
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
)

zephyr_include_directories(
src/
${ZEPHYR_BASE}/tests/bluetooth/tester/src
${ZEPHYR_BASE}/tests/bluetooth/tester/src/btp
${ZEPHYR_BASE}/tests/bluetooth/tester/src/audio/btp
)

target_sources(app PRIVATE
src/bsim_btp.c
src/test_main.c
src/host/gap_central.c
src/host/gap_peripheral.c
)
8 changes: 8 additions & 0 deletions tests/bsim/bluetooth/tester/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

module = BSIM_BTTESTER
module-str = bsim_bttester
source "subsys/logging/Kconfig.template.log_config"

source "Kconfig.zephyr"
5 changes: 5 additions & 0 deletions tests/bsim/bluetooth/tester/boards/nrf52_bsim.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: Apache-2.0 */

&uart0 {
hw-flow-control;
};
21 changes: 21 additions & 0 deletions tests/bsim/bluetooth/tester/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Copyright 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

# Compile all the applications needed by the bsim tests in these subfolders

#set -x #uncomment this line for debugging
set -ue

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

: "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root directory}"

# We only want to build the tests/bsim/bluetooth/tester/ application for the nrf52_bsim/native board
# as we do not gain anything from running this application for the nrf5340bsim_nrf5340_cpuapp and
# it is not worth the added complexity to run it with anything but nrf52_bsim/native
west twister -T ${ZEPHYR_BASE}/tests/bsim/bluetooth/tester/

west twister -p ${BOARD} -T ${ZEPHYR_BASE}/tests/bluetooth/tester/

wait_for_background_jobs
14 changes: 14 additions & 0 deletions tests/bsim/bluetooth/tester/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CONFIG_ASSERT=y
CONFIG_THREAD_NAME=y

# Should not be necessary, but the bluetooth/buf.h header file require Bluetooth to be enabled, and
# the header file is being included by some of the BTP header files
CONFIG_BT=y

CONFIG_UART_PIPE=n
CONFIG_SERIAL=y

CONFIG_LOG=y
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
CONFIG_BSIM_BTTESTER_LOG_LEVEL_DBG=y
Loading