Skip to content

Commit d3bae1d

Browse files
lylezhu2012jhedberg
authored andcommitted
tests: Bluetooth: SDP: Wait for DUT connect event before send any cmd
There is a corner case found that the ACL connected event may be printed when script is sending shell command by calling function `shell.exec_command()`. The echo of shell command will mix with the ACL connected event message. The received message cannot be recognized by the function `shell.exec_command()`. It caused the timeout exception reported by the function `shell.exec_command()`. Before sending any shell commands, check the DUT connected event after the connection is established on script side. Signed-off-by: Lyle Zhu <[email protected]>
1 parent 40256a9 commit d3bae1d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ async def sdp_ssa_discover_no_record(hci_port, shell, dut, address) -> None:
375375
logger.error(f'Fail to connect to {target_address}!')
376376
raise e
377377

378+
await wait_for_shell_response(dut, "Connected:")
379+
378380
# Discover SDP Record
379381
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
380382
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -408,6 +410,8 @@ async def sdp_ssa_discover_one_record(hci_port, shell, dut, address) -> None:
408410
logger.error(f'Fail to connect to {target_address}!')
409411
raise e
410412

413+
await wait_for_shell_response(dut, "Connected:")
414+
411415
# Discover SDP Record
412416
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
413417
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -465,6 +469,8 @@ async def sdp_ssa_discover_two_records(hci_port, shell, dut, address) -> None:
465469
logger.error(f'Fail to connect to {target_address}!')
466470
raise e
467471

472+
await wait_for_shell_response(dut, "Connected:")
473+
468474
# Discover SDP Record
469475
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
470476
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -535,6 +541,8 @@ async def sdp_ssa_discover_multiple_records(hci_port, shell, dut, address) -> No
535541
logger.error(f'Fail to connect to {target_address}!')
536542
raise e
537543

544+
await wait_for_shell_response(dut, "Connected:")
545+
538546
# Discover SDP Record
539547
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
540548
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -568,6 +576,8 @@ async def sdp_ssa_discover_multiple_records_with_range(hci_port, shell, dut, add
568576
logger.error(f'Fail to connect to {target_address}!')
569577
raise e
570578

579+
await wait_for_shell_response(dut, "Connected:")
580+
571581
# Discover SDP Record with range SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID ~
572582
# SDP_PROTOCOL_DESCRIPTOR_LIST_ATTRIBUTE_ID
573583
shell.exec_command(
@@ -636,6 +646,8 @@ async def sdp_ss_discover_no_record(hci_port, shell, dut, address) -> None:
636646
logger.error(f'Fail to connect to {target_address}!')
637647
raise e
638648

649+
await wait_for_shell_response(dut, "Connected:")
650+
639651
# Discover SDP Record
640652
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
641653
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -669,6 +681,8 @@ async def sdp_ss_discover_one_record(hci_port, shell, dut, address) -> None:
669681
logger.error(f'Fail to connect to {target_address}!')
670682
raise e
671683

684+
await wait_for_shell_response(dut, "Connected:")
685+
672686
# Discover SDP Record
673687
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
674688
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -712,6 +726,8 @@ async def sdp_ss_discover_two_records(hci_port, shell, dut, address) -> None:
712726
logger.error(f'Fail to connect to {target_address}!')
713727
raise e
714728

729+
await wait_for_shell_response(dut, "Connected:")
730+
715731
# Discover SDP Record
716732
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
717733
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -755,6 +771,8 @@ async def sdp_ss_discover_multiple_records(hci_port, shell, dut, address) -> Non
755771
logger.error(f'Fail to connect to {target_address}!')
756772
raise e
757773

774+
await wait_for_shell_response(dut, "Connected:")
775+
758776
# Discover SDP Record
759777
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
760778
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -799,6 +817,8 @@ async def sdp_sa_discover_no_record(hci_port, shell, dut, address) -> None:
799817
logger.error(f'Fail to connect to {target_address}!')
800818
raise e
801819

820+
await wait_for_shell_response(dut, "Connected:")
821+
802822
# Discover SDP Record
803823
shell.exec_command("sdp_client sa_discovery 00010001")
804824
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -832,6 +852,8 @@ async def sdp_sa_discover_one_record(hci_port, shell, dut, address) -> None:
832852
logger.error(f'Fail to connect to {target_address}!')
833853
raise e
834854

855+
await wait_for_shell_response(dut, "Connected:")
856+
835857
# Discover SDP Record
836858
shell.exec_command("sdp_client sa_discovery 00010001")
837859
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -886,6 +908,8 @@ async def sdp_sa_discover_two_records(hci_port, shell, dut, address) -> None:
886908
logger.error(f'Fail to connect to {target_address}!')
887909
raise e
888910

911+
await wait_for_shell_response(dut, "Connected:")
912+
889913
# Discover SDP Record
890914
shell.exec_command("sdp_client sa_discovery 00010002")
891915
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -949,6 +973,8 @@ async def sdp_sa_discover_multiple_records(hci_port, shell, dut, address) -> Non
949973
logger.error(f'Fail to connect to {target_address}!')
950974
raise e
951975

976+
await wait_for_shell_response(dut, "Connected:")
977+
952978
# Discover SDP Record
953979
shell.exec_command("sdp_client sa_discovery 00010003")
954980
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -982,6 +1008,8 @@ async def sdp_sa_discover_multiple_records_with_range(hci_port, shell, dut, addr
9821008
logger.error(f'Fail to connect to {target_address}!')
9831009
raise e
9841010

1011+
await wait_for_shell_response(dut, "Connected:")
1012+
9851013
# Discover SDP Record with range SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID ~
9861014
# SDP_PROTOCOL_DESCRIPTOR_LIST_ATTRIBUTE_ID
9871015
shell.exec_command(
@@ -1062,6 +1090,8 @@ def on_app_connection_request(self, request) -> None:
10621090
logger.error(f'Fail to connect to {target_address}!')
10631091
raise e
10641092

1093+
await wait_for_shell_response(dut, "Connected:")
1094+
10651095
# Discover SDP Record
10661096
shell.exec_command("sdp_client ssa_discovery_fail")
10671097
found, lines = await wait_for_shell_response(dut, "test pass")

0 commit comments

Comments
 (0)