Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] mgmt-tester: Add test for Device Connected with missing remote features
@ 2026-12-03 20:55 Luiz Augusto von Dentz
  2026-12-04  8:15 ` [BlueZ,v1] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2026-12-03 20:55 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Add "Pairing Acceptor - SSP Device Connected" which has the remote
initiate the connection and pairing while dropping the Read Remote
Supported Features Complete event, so encryption completes first, and
checks that MGMT_EV_DEVICE_CONNECTED is still emitted.

Link: https://github.com/bluez/bluez/issues/2485
Assisted-by: OpenCode:claude-opus-5.5
---
 tools/mgmt-tester.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 18dbd3f89096..acf40b8a2aad 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4137,6 +4137,43 @@ static const struct generic_data pairing_acceptor_ssp_sec_level_changed = {
 	.just_works = true,
 };
 
+static bool verify_device_connected(const void *param, uint16_t length)
+{
+	struct test_data *data = tester_get_data();
+	const struct mgmt_ev_device_connected *ev = param;
+	const uint8_t *bdaddr;
+
+	if (length < sizeof(*ev)) {
+		tester_warn("Invalid length %u < %zu", length, sizeof(*ev));
+		return false;
+	}
+
+	bdaddr = hciemu_get_client_bdaddr(data->hciemu);
+	if (memcmp(&ev->addr.bdaddr, bdaddr, 6)) {
+		tester_warn("Unexpected address");
+		return false;
+	}
+
+	if (ev->addr.type != BDADDR_BREDR) {
+		tester_warn("Unexpected address type %u", ev->addr.type);
+		return false;
+	}
+
+	return true;
+}
+
+static const struct generic_data pairing_acceptor_ssp_dev_connected = {
+	.setup_settings = settings_powered_connectable_bondable_ssp,
+	.client_enable_ssp = true,
+	.expect_alt_ev = MGMT_EV_DEVICE_CONNECTED,
+	.verify_alt_ev_func = verify_device_connected,
+	.expect_hci_command = BT_HCI_CMD_USER_CONFIRM_REQUEST_REPLY,
+	.expect_hci_func = client_bdaddr_param_func,
+	.io_cap = 0x03, /* NoInputNoOutput */
+	.client_io_cap = 0x03, /* NoInputNoOutput */
+	.just_works = true,
+};
+
 static const struct generic_data pairing_acceptor_ssp_2 = {
 	.setup_settings = settings_powered_connectable_bondable_ssp,
 	.client_enable_ssp = true,
@@ -13241,6 +13278,33 @@ static void test_pairing_acceptor(const void *test_data)
 	bthost_hci_connect(bthost, central_bdaddr, addr_type);
 }
 
+static bool hook_drop_remote_features(const void *data, uint16_t len,
+							void *user_data)
+{
+	tester_print("Dropping Read Remote Supported Features Complete");
+
+	return false;
+}
+
+/* Simulate a remote initiated connection where encryption completes before
+ * Read Remote Supported Features Complete, by never delivering the latter,
+ * and check that MGMT_EV_DEVICE_CONNECTED is still emitted.
+ */
+static void test_pairing_acceptor_no_features(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	if (hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT,
+				BT_HCI_CMD_READ_REMOTE_FEATURES,
+				hook_drop_remote_features, data) < 0) {
+		tester_warn("Unable to add emulator hook");
+		tester_test_failed();
+		return;
+	}
+
+	test_pairing_acceptor(test_data);
+}
+
 
 static void check_le_ext_adv_discovery(void *user_data)
 {
@@ -15239,6 +15303,10 @@ int main(int argc, char *argv[])
 	test_bredrle("Pairing Acceptor - SSP Security Level Changed",
 				&pairing_acceptor_ssp_sec_level_changed,
 				setup_pairing_acceptor, test_pairing_acceptor);
+	test_bredrle("Pairing Acceptor - SSP Device Connected",
+				&pairing_acceptor_ssp_dev_connected,
+				setup_pairing_acceptor,
+				test_pairing_acceptor_no_features);
 	test_bredrle("Pairing Acceptor - SSP 2",
 				&pairing_acceptor_ssp_2, setup_pairing_acceptor,
 				test_pairing_acceptor);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 20:55 [PATCH BlueZ v1] mgmt-tester: Add test for Device Connected with missing remote features Luiz Augusto von Dentz
2026-12-04  8:15 ` [BlueZ,v1] " bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox