Skip to content

Commit 8a47f0e

Browse files
committed
tests: Bluetooth: Classic: Add test suites gap_discovery
Add test cases gap_central.test_01_gap_central_general_discovery and gap_central.test_02_gap_central_limited_discovery. Add test cases gap_peripheral.test_01_gap_peripheral_general_discovery and gap_peripheral.test_02_gap_peripheral_limited_discovery. Signed-off-by: Lyle Zhu <[email protected]>
1 parent d14a547 commit 8a47f0e

File tree

8 files changed

+1366
-0
lines changed

8 files changed

+1366
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
set(NO_QEMU_SERIAL_BT_SERVER 1)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(bluetooth)
8+
9+
if(CONFIG_TEST_GAP_PERIPHERAL)
10+
FILE(GLOB app_sources src/test_peripheral.c)
11+
endif ()
12+
13+
if(CONFIG_TEST_GAP_CENTRAL)
14+
FILE(GLOB app_sources src/test_central.c)
15+
endif()
16+
17+
target_sources(app PRIVATE ${app_sources})
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2025 NXP
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source "Kconfig.zephyr"
6+
7+
choice TEST_GAP_ROLE
8+
prompt "GAP Role"
9+
default TEST_GAP_PERIPHERAL
10+
help
11+
Select the GAP role for testing
12+
13+
config TEST_GAP_PERIPHERAL
14+
bool "GAP Role Peripheral"
15+
help
16+
Test GAP role as peripheral device
17+
18+
config TEST_GAP_CENTRAL
19+
bool "GAP Role Central"
20+
help
21+
Test GAP role as central device
22+
23+
endchoice
24+
25+
config TEST_GAP_CENTRAL_ADDRESS
26+
string "Central Device Address"
27+
default "00:11:22:33:44:55"
28+
help
29+
GAP central device Bluetooth address in format XX:XX:XX:XX:XX:XX
30+
31+
config TEST_GAP_PERIPHERAL_ADDRESS
32+
string "Peripheral Device Address"
33+
default "AA:BB:CC:DD:EE:FF"
34+
help
35+
GAP peripheral device Bluetooth address in format XX:XX:XX:XX:XX:XX
36+
37+
module = TEST_GAP_DISCOVERY
38+
module-str = test_gap_discovery
39+
source "subsys/logging/Kconfig.template.log_config"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. _bluetooth_classic_gap_discovery_test:
2+
3+
Bluetooth Classic GAP Discovery Test
4+
#####################################
5+
6+
Overview
7+
********
8+
9+
This test verifies the Bluetooth Classic GAP (Generic Access Profile) discovery
10+
functionality. It tests the device's ability to discover nearby Bluetooth Classic
11+
devices through inquiry procedures.
12+
13+
Requirements
14+
************
15+
16+
* A board with Bluetooth Classic support
17+
* Bluetooth Classic controller enabled in the configuration
18+
19+
Building and Running
20+
********************
21+
22+
This test can be built and executed on boards with Bluetooth Classic support.
23+
24+
.. code-block:: console
25+
26+
./tests/bluetooth/classic/gap_discovery/tests_scripts/gap_discovery_run.sh
27+
28+
If the error "Permission denied" occurs, the following command should be used to add permission for
29+
the script.
30+
31+
.. code-block:: console
32+
33+
chmod +x ./tests/bluetooth/classic/gap_discovery/tests_scripts/gap_discovery_run.sh
34+
35+
If the error "west: command not found" occurs, the following command should be used to activate the
36+
virtual environment. Refer to :ref:`getting_started` for details.
37+
38+
.. code-block:: console
39+
40+
source ~/zephyrproject/.venv/bin/activate
41+
42+
Sample Output
43+
*************
44+
45+
.. code-block:: console
46+
47+
------ TESTSUITE SUMMARY START ------
48+
49+
SUITE PASS - 100.00% [gap_central]: pass = 2, fail = 0, skip = 0, total = 2 duration = 46.640 seconds
50+
- PASS - [gap_central.test_01_gap_central_general_discovery] duration = 5.180 seconds
51+
- PASS - [gap_central.test_02_gap_central_limited_discovery] duration = 41.460 seconds
52+
53+
------ TESTSUITE SUMMARY END ------
54+
55+
------ TESTSUITE SUMMARY START ------
56+
57+
SUITE PASS - 100.00% [gap_peripheral]: pass = 2, fail = 0, skip = 0, total = 2 duration = 48.620 seconds
58+
- PASS - [gap_peripheral.test_01_gap_peripheral_general_discovery] duration = 7.180 seconds
59+
- PASS - [gap_peripheral.test_02_gap_peripheral_limited_discovery] duration = 41.440 seconds
60+
61+
------ TESTSUITE SUMMARY END ------
62+
63+
Test Coverage
64+
*************
65+
66+
This test covers:
67+
68+
* Bluetooth Classic initialization
69+
* GAP inquiry start/stop procedures
70+
* Device discovery callbacks
71+
* Inquiry result handling
72+
73+
Configuration Options
74+
*********************
75+
76+
See :file:`prj.conf` for the default configuration.
77+
78+
Additional configuration options can be found in :file:`Kconfig`.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CONFIG_BT=y
2+
CONFIG_BT_CLASSIC=y
3+
CONFIG_LOG=y
4+
CONFIG_ZTEST=y
5+
6+
CONFIG_BT_DEVICE_NAME="gap_discovery"
7+
8+
CONFIG_BT_CREATE_CONN_TIMEOUT=30
9+
CONFIG_BT_PAGE_TIMEOUT=0xFFFF
10+
CONFIG_BT_LIMITED_DISCOVERABLE_DURATION=31
11+
12+
CONFIG_TEST_GAP_DISCOVERY_LOG_LEVEL_DBG=y

0 commit comments

Comments
 (0)