IUT works as an RFCOMM Client. The peer device, RFCOMM server, is a PC running bumble. In the test suite, there are five test cases: Case 1, RFCOMM Client with Command Responses. Tests that the client can establish a DLC, respond to various commands (RLS, RPN, Test), send NSC responses, and properly handle DLC disconnection and RFCOMM session shutdown. Case 2, RFCOMM Client with Credit Based Flow Control. Tests that the client can establish a DLC, perform information transfer with credit based flow control, initiate disconnection, and shutdown the RFCOMM session. Case 3, RFCOMM Client with BR Connection Disconnection. Tests that the client correctly handles scenarios where the BR connection is disconnected during DLC establishment. Case 4, RFCOMM Client with Aggregate Flow Control. Tests that the client can establish a DLC, perform information transfer with aggregate flow control, and properly handle disconnection and session shutdown. Case 5, RFCOMM Client with Failed PN Response. Tests that the client correctly handles scenarios where it fails to receive a PN response when establishing a DLC. Signed-off-by: Jiawei Yang <jiawei.yang_1@nxp.com>
56 lines
1.5 KiB
Python
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>([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}) *\((.*?)\))'
|
|
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')
|