Skip to content

Commit 00ffb5b

Browse files
lylezhu2012kartben
authored andcommitted
Tests: Bluetooth: Classic: Bumble power_on() will fail on Linux
On Linux, the function `power_on()` of Bumble will fail when executing even-numbered test cases. From the `btmon` log, the controller will not reply the `HCI Command: Reset` when the issue occurs. Add a try-except to catch the exception of the function `power_on()`, and retry to call the function `power_on()` until issue no longer occurs. Or, the test will fail due to the timeout. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent 483c767 commit 00ffb5b

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

tests/bluetooth/classic/sdp_c/pytest/test_sdp.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ async def wait_for_shell_response(dut, message):
338338
return found, lines
339339

340340

341+
async def device_power_on(device) -> None:
342+
while True:
343+
try:
344+
await device.power_on()
345+
break
346+
except Exception:
347+
continue
348+
349+
341350
async def sdp_ssa_discover_no_record(hci_port, shell, dut, address) -> None:
342351
logger.info('<<< SDP Discovery ...')
343352
async with await open_transport_or_link(hci_port) as hci_transport:
@@ -353,7 +362,7 @@ async def sdp_ssa_discover_no_record(hci_port, shell, dut, address) -> None:
353362
# device.sdp_service_records = SDP_SERVICE_RECORDS
354363
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
355364
device.host.snooper = BtSnooper(snoop_file)
356-
await device.power_on()
365+
await device_power_on(device)
357366
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
358367

359368
target_address = address.split(" ")[0]
@@ -386,7 +395,7 @@ async def sdp_ssa_discover_one_record(hci_port, shell, dut, address) -> None:
386395
device.sdp_service_records = SDP_SERVICE_ONE_RECORD
387396
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
388397
device.host.snooper = BtSnooper(snoop_file)
389-
await device.power_on()
398+
await device_power_on(device)
390399
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
391400

392401
target_address = address.split(" ")[0]
@@ -443,7 +452,7 @@ async def sdp_ssa_discover_two_records(hci_port, shell, dut, address) -> None:
443452
device.sdp_service_records = SDP_SERVICE_TWO_RECORDS
444453
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
445454
device.host.snooper = BtSnooper(snoop_file)
446-
await device.power_on()
455+
await device_power_on(device)
447456
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
448457

449458
target_address = address.split(" ")[0]
@@ -513,7 +522,7 @@ async def sdp_ssa_discover_multiple_records(hci_port, shell, dut, address) -> No
513522
device.sdp_service_records = SDP_SERVICE_MULTIPLE_RECORDS
514523
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
515524
device.host.snooper = BtSnooper(snoop_file)
516-
await device.power_on()
525+
await device_power_on(device)
517526
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
518527

519528
target_address = address.split(" ")[0]
@@ -547,7 +556,7 @@ async def sdp_ss_discover_no_record(hci_port, shell, dut, address) -> None:
547556
# device.sdp_service_records = SDP_SERVICE_RECORDS
548557
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
549558
device.host.snooper = BtSnooper(snoop_file)
550-
await device.power_on()
559+
await device_power_on(device)
551560
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
552561

553562
target_address = address.split(" ")[0]
@@ -580,7 +589,7 @@ async def sdp_ss_discover_one_record(hci_port, shell, dut, address) -> None:
580589
device.sdp_service_records = SDP_SERVICE_ONE_RECORD
581590
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
582591
device.host.snooper = BtSnooper(snoop_file)
583-
await device.power_on()
592+
await device_power_on(device)
584593
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
585594

586595
target_address = address.split(" ")[0]
@@ -623,7 +632,7 @@ async def sdp_ss_discover_two_records(hci_port, shell, dut, address) -> None:
623632
device.sdp_service_records = SDP_SERVICE_TWO_RECORDS
624633
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
625634
device.host.snooper = BtSnooper(snoop_file)
626-
await device.power_on()
635+
await device_power_on(device)
627636
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
628637

629638
target_address = address.split(" ")[0]
@@ -666,7 +675,7 @@ async def sdp_ss_discover_multiple_records(hci_port, shell, dut, address) -> Non
666675
device.sdp_service_records = SDP_SERVICE_MULTIPLE_RECORDS
667676
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
668677
device.host.snooper = BtSnooper(snoop_file)
669-
await device.power_on()
678+
await device_power_on(device)
670679
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
671680

672681
target_address = address.split(" ")[0]
@@ -710,7 +719,7 @@ async def sdp_sa_discover_no_record(hci_port, shell, dut, address) -> None:
710719
# device.sdp_service_records = SDP_SERVICE_RECORDS
711720
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
712721
device.host.snooper = BtSnooper(snoop_file)
713-
await device.power_on()
722+
await device_power_on(device)
714723
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
715724

716725
target_address = address.split(" ")[0]
@@ -743,7 +752,7 @@ async def sdp_sa_discover_one_record(hci_port, shell, dut, address) -> None:
743752
device.sdp_service_records = SDP_SERVICE_ONE_RECORD
744753
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
745754
device.host.snooper = BtSnooper(snoop_file)
746-
await device.power_on()
755+
await device_power_on(device)
747756
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
748757

749758
target_address = address.split(" ")[0]
@@ -797,7 +806,7 @@ async def sdp_sa_discover_two_records(hci_port, shell, dut, address) -> None:
797806
device.sdp_service_records = SDP_SERVICE_TWO_RECORDS
798807
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
799808
device.host.snooper = BtSnooper(snoop_file)
800-
await device.power_on()
809+
await device_power_on(device)
801810
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
802811

803812
target_address = address.split(" ")[0]
@@ -860,7 +869,7 @@ async def sdp_sa_discover_multiple_records(hci_port, shell, dut, address) -> Non
860869
device.sdp_service_records = SDP_SERVICE_MULTIPLE_RECORDS
861870
with open(f"bumble_hci_{sys._getframe().f_code.co_name}.log", "wb") as snoop_file:
862871
device.host.snooper = BtSnooper(snoop_file)
863-
await device.power_on()
872+
await device_power_on(device)
864873
await device.send_command(HCI_Write_Page_Timeout_Command(page_timeout=0xFFFF))
865874

866875
target_address = address.split(" ")[0]

tests/bluetooth/classic/sdp_s/pytest/test_sdp.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
logger = logging.getLogger(__name__)
2323

2424

25+
async def device_power_on(device) -> None:
26+
while True:
27+
try:
28+
await device.power_on()
29+
break
30+
except Exception:
31+
continue
32+
33+
2534
class discovery_listener(Device.Listener):
2635
def __init__(self, address: str, event, **kwargs):
2736
self._address = address
@@ -67,7 +76,8 @@ async def start_discovery(hci_port, address) -> None:
6776
hci_transport.sink,
6877
)
6978
device.listener = discovery_listener(address, event)
70-
await device.power_on()
79+
await device_power_on(device)
80+
7181
logger.info('Starting discovery')
7282
await device.start_discovery()
7383
await event.wait()
@@ -84,7 +94,7 @@ async def br_connect(hci_port, shell, address) -> None:
8494
)
8595
device.classic_enabled = True
8696
device.le_enabled = False
87-
await device.power_on()
97+
await device_power_on(device)
8898

8999
target_address = address.split(" ")[0]
90100
logger.info(f'=== Connecting to {target_address}...')

0 commit comments

Comments
 (0)