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 <lyle.zhu@nxp.com>
diff --git a/tests/bluetooth/classic/sdp_c/pytest/test_sdp.py b/tests/bluetooth/classic/sdp_c/pytest/test_sdp.py
index 9d9184b..d728af7 100644
--- a/tests/bluetooth/classic/sdp_c/pytest/test_sdp.py
+++ b/tests/bluetooth/classic/sdp_c/pytest/test_sdp.py
@@ -375,6 +375,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -408,6 +410,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -465,6 +469,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -535,6 +541,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ssa_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -568,6 +576,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record with range SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID ~
# SDP_PROTOCOL_DESCRIPTOR_LIST_ATTRIBUTE_ID
shell.exec_command(
@@ -636,6 +646,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -669,6 +681,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -712,6 +726,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -755,6 +771,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command(f"sdp_client ss_discovery {BT_L2CAP_PROTOCOL_ID.to_hex_str()}")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -799,6 +817,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command("sdp_client sa_discovery 00010001")
found, lines = await wait_for_shell_response(dut, "No SDP Record")
@@ -832,6 +852,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command("sdp_client sa_discovery 00010001")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -886,6 +908,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command("sdp_client sa_discovery 00010002")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -949,6 +973,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command("sdp_client sa_discovery 00010003")
found, lines = await wait_for_shell_response(dut, "SDP Discovery Done")
@@ -982,6 +1008,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record with range SDP_SERVICE_RECORD_HANDLE_ATTRIBUTE_ID ~
# SDP_PROTOCOL_DESCRIPTOR_LIST_ATTRIBUTE_ID
shell.exec_command(
@@ -1062,6 +1090,8 @@
logger.error(f'Fail to connect to {target_address}!')
raise e
+ await wait_for_shell_response(dut, "Connected:")
+
# Discover SDP Record
shell.exec_command("sdp_client ssa_discovery_fail")
found, lines = await wait_for_shell_response(dut, "test pass")