Skip to content

Commit d8e771d

Browse files
Thalleykartben
authored andcommitted
tests: Bluetooth: Add BT Tester GAP smoke test
Add a babblesim test of the BT Tester doing a GAP smoke test connecting 2 BT testers using BTP. The purpose of this is to further increase the test coverage of the BT Tester in CI, as it is only being built, and runtime errors are typically not caught. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 39a65c0 commit d8e771d

22 files changed

+2503
-0
lines changed

tests/bluetooth/tester/Kconfig.sysbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config NET_CORE_BOARD
77
string
88
default "nrf5340dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340dk"
99
default "nrf5340_audio_dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340_audio_dk"
10+
default "nrf5340bsim/nrf5340/cpunet" if $(BOARD_TARGET_STRING) = "NRF5340BSIM_NRF5340_CPUAPP"
1011

1112
config NET_CORE_IMAGE_HCI_IPC
1213
bool "HCI IPC image on network core"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CONFIG_TEST enforces minimal logging, which we don't want
2+
CONFIG_TEST=n
3+
4+
CONFIG_ASSERT=y
5+
CONFIG_THREAD_NAME=y
6+
7+
CONFIG_LOG=y
8+
CONFIG_LOG_BACKEND_SHOW_COLOR=y
9+
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
10+
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
11+
12+
CONFIG_LOG_DEFAULT_LEVEL=3
13+
CONFIG_BTTESTER_LOG_LEVEL_DBG=y
14+
15+
CONFIG_UART_PIPE=n
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&uart0 {
4+
hw-flow-control;
5+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# CONFIG_TEST enforces minimal logging, which we don't want
2+
CONFIG_TEST=n
3+
4+
CONFIG_ASSERT=y
5+
CONFIG_THREAD_NAME=y
6+
7+
CONFIG_LOG=y
8+
CONFIG_LOG_BACKEND_SHOW_COLOR=y
9+
CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y
10+
CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y
11+
12+
CONFIG_LOG_DEFAULT_LEVEL=3
13+
CONFIG_BTTESTER_LOG_LEVEL_DBG=y
14+
15+
CONFIG_UART_PIPE=n
16+
CONFIG_UART_INTERRUPT_DRIVEN=y
17+
18+
CONFIG_SERIAL=y
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
3+
&uart0 {
4+
compatible = "nordic,nrf-uarte";
5+
hw-flow-control;
6+
};

tests/bluetooth/tester/src/btp/btp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* SPDX-License-Identifier: Apache-2.0
88
*/
99

10+
#ifndef TESTS_BLUETOOTH_TESTER_SRC_BTP_
11+
#define TESTS_BLUETOOTH_TESTER_SRC_BTP_
12+
1013
#include <zephyr/sys/util.h>
1114
#include <zephyr/bluetooth/addr.h>
1215

@@ -87,6 +90,8 @@
8790

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

93+
#define BTP_EVENT_OPCODE 0x80
94+
9095
/* TODO indicate delay response, should be removed when all commands are
9196
* converted to cmd+status+ev pattern
9297
*/
@@ -104,3 +109,5 @@ struct btp_hdr {
104109
struct btp_status {
105110
uint8_t code;
106111
} __packed;
112+
113+
#endif /* TESTS_BLUETOOTH_TESTER_SRC_BTP_ */

tests/bluetooth/tester/testcase.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
common:
2+
build_only: true
3+
tags: bluetooth
4+
15
tests:
26
bluetooth.general.tester:
37
build_only: true
@@ -7,6 +11,12 @@ tests:
711
- nrf52840dk/nrf52840
812
tags: bluetooth
913
harness: bluetooth
14+
bluetooth.general.tester_bsim:
15+
platform_allow:
16+
- nrf52_bsim/native
17+
harness: bsim
18+
harness_config:
19+
bsim_exe_name: tests_bluetooth_tester_prj_conf
1020
bluetooth.general.tester.nxp:
1121
# Disabling monolithic since CI environment doesn't use blobs
1222
build_only: true
@@ -30,6 +40,16 @@ tests:
3040
- EXTRA_CONF_FILE="hci_ipc.conf"
3141
tags: bluetooth
3242
sysbuild: true
43+
bluetooth.general.tester_hci_ipc_bsim:
44+
platform_allow:
45+
- nrf5340bsim/nrf5340/cpuapp
46+
harness: bsim
47+
harness_config:
48+
bsim_exe_name: tests_bluetooth_tester_prj_conf
49+
extra_args:
50+
# Build config used by AutoPTS for nRF53
51+
- EXTRA_CONF_FILE="hci_ipc.conf"
52+
sysbuild: true
3353
bluetooth.general.tester_le_audio:
3454
build_only: true
3555
platform_allow:

tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpuapp.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export BOARD="${BOARD:-nrf5340bsim/nrf5340/cpuapp}"
1313
source ${ZEPHYR_BASE}/tests/bsim/compile.source
1414

1515
${ZEPHYR_BASE}/tests/bsim/bluetooth/host/compile.sh
16+
${ZEPHYR_BASE}/tests/bsim/bluetooth/tester/compile.sh
1617

1718
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_privacy.conf sysbuild=1 compile
1819
app=tests/bsim/bluetooth/ll/throughput sysbuild=1 compile

tests/bsim/bluetooth/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ ${ZEPHYR_BASE}/tests/bsim/bluetooth/samples/compile.sh
2424
if [ ${BOARD} == "nrf52_bsim/native" ]; then
2525
${ZEPHYR_BASE}/tests/bsim/bluetooth/hci_uart/compile.sh
2626
fi
27+
${ZEPHYR_BASE}/tests/bsim/bluetooth/tester/compile.sh
2728

2829
wait_for_background_jobs
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(tester_bsim)
7+
8+
# This contains babblesim-specific helpers, e.g. device synchronization.
9+
add_subdirectory(${ZEPHYR_BASE}/tests/bsim/babblekit babblekit)
10+
target_link_libraries(app PRIVATE babblekit)
11+
12+
zephyr_include_directories(
13+
${BSIM_COMPONENTS_PATH}/libUtilv1/src/
14+
${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
15+
)
16+
17+
zephyr_include_directories(
18+
src/
19+
${ZEPHYR_BASE}/tests/bluetooth/tester/src
20+
${ZEPHYR_BASE}/tests/bluetooth/tester/src/btp
21+
${ZEPHYR_BASE}/tests/bluetooth/tester/src/audio/btp
22+
)
23+
24+
target_sources(app PRIVATE
25+
src/bsim_btp.c
26+
src/test_main.c
27+
src/host/gap_central.c
28+
src/host/gap_peripheral.c
29+
)

0 commit comments

Comments
 (0)