zephyr/tests/bluetooth/classic/gap_c/pytest/conftest.py
Jiawei Yang b2340babdf tests: Bluetooth: BR: Add test suite gap_client
IUT works as a Bluetooth GAP Client. The peer device (tester) is
configured to respond to inquiries and process connection requests.

Add tests to verify GAP client functionality for inquiry, connection,
and disconnection scenarios.

In the test suite, there are six test cases:
Case 1: General Inquiry followed by Connection and Active Disconnection.
Verifies that DUT can perform general inquiry, establish connection, and
actively disconnect from tester.
Case 2: General Inquiry followed by Connection and Passive
Disconnection. Verifies that DUT can perform general inquiry, establish
connection, and handle disconnection initiated by tester.
Case 3: General Inquiry followed by Rejected Connection Request.
Verifies that DUT can perform general inquiry and handle connection
rejection from tester.
Case 4: Limited Inquiry followed by Connection and Active Disconnection.
Verifies that DUT can perform limited inquiry, establish connection, and
actively disconnect from tester.
Case 5: Limited Inquiry followed by Connection and Passive
Disconnection. Verifies that DUT can perform limited inquiry, establish
connection, and handle disconnection initiated by tester.
Case 6: Limited Inquiry followed by Rejected Connection Request.
Verifies that DUT can perform limited inquiry and handle connection
rejection from tester.

Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
2025-05-29 20:21:50 -04:00

56 lines
1.5 KiB
Python

# Copyright 2025 NXP
#
# SPDX-License-Identifier: Apache-2.0
import logging
import re
import pytest
from twister_harness import DeviceAdapter, Shell
logger = logging.getLogger(__name__)
def pytest_addoption(parser) -> None:
"""Add local parser options to pytest."""
parser.addoption('--hci-transport', default=None, help='Configuration HCI transport for bumble')
@pytest.fixture(name='initialize', scope='session')
def fixture_initialize(request, shell: Shell, dut: DeviceAdapter):
"""Session initializtion"""
# Get HCI transport for bumble
hci = request.config.getoption('--hci-transport')
if hci is None:
for fixture in dut.device_config.fixtures:
if fixture.startswith('usb_hci:'):
hci = fixture.split(sep=':', maxsplit=1)[1]
break
assert hci is not None
lines = shell.exec_command("bt init")
lines = dut.readlines_until("Bluetooth initialized")
regex = r'Identity: (?P<bd_addr>(.*?):(.*?):(.*?):(.*?):(.*?):(.*?) *\((.*?)\))'
bd_addr = None
for line in lines:
logger.info(f"Shell log {line}")
m = re.search(regex, line)
if m:
bd_addr = m.group('bd_addr')
if bd_addr is None:
logger.error('Fail to get IUT BD address')
raise AssertionError
logger.info('initialized')
return hci, bd_addr
@pytest.fixture
def device_under_test(initialize):
logger.info('Start running testcase')
yield initialize
logger.info('Done')