Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] mgmt-tester: Add test for Device Connected with missing remote features
Date: Thu,  3 Dec 2026 15:55:25 -0500	[thread overview]
Message-ID: <20261203205525.950813-1-luiz.dentz@gmail.com> (raw)

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


             reply	other threads:[~2026-12-03 20:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 20:55 Luiz Augusto von Dentz [this message]
2026-12-04  8:15 ` [BlueZ,v1] mgmt-tester: Add test for Device Connected with missing remote features bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203205525.950813-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox