linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] l2cap-test: Add tests for BT_PHY
@ 2025-12-10 20:49 Luiz Augusto von Dentz
  2025-12-10 21:46 ` [BlueZ,v1] " bluez.test.bot
  2025-12-11 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2025-12-10 20:49 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds the following tests that uses BT_PHY to retrieve the ACL/LE
connection supported PHYs:

L2CAP BR/EDR Client - PHY
L2CAP BR/EDR Server - PHY
L2CAP LE Client - PHY
L2CAP LE Server - PHY
L2CAP Ext-Flowctl Client - PHY
L2CAP Ext-Flowctl Server - PHY
---
 tools/l2cap-tester.c | 110 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 109 insertions(+), 1 deletion(-)

diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index a9ab8b05166f..2706a4b33f7b 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -46,6 +46,7 @@ struct test_data {
 	uint16_t scid;
 	uint16_t dcid;
 	struct l2cap_options l2o;
+	uint32_t phys;
 	int sk;
 	int sk2;
 	bool host_disconnected;
@@ -105,6 +106,9 @@ struct l2cap_data {
 
 	/* Socket type (0 means SOCK_SEQPACKET) */
 	int sock_type;
+
+	/* Expected supported PHYs */
+	uint32_t phys;
 };
 
 static void print_debug(const char *str, void *user_data)
@@ -420,6 +424,14 @@ static const struct l2cap_data client_connect_shut_wr_success_test = {
 	.shut_sock_wr = true,
 };
 
+static const struct l2cap_data client_connect_phy_test_1 = {
+	.client_psm = 0x1001,
+	.server_psm = 0x1001,
+	.phys = (BT_PHY_BR_1M_1SLOT |
+	BT_PHY_EDR_2M_1SLOT | BT_PHY_EDR_2M_3SLOT | BT_PHY_EDR_2M_5SLOT |
+	BT_PHY_EDR_3M_1SLOT | BT_PHY_EDR_3M_3SLOT | BT_PHY_EDR_3M_5SLOT),
+};
+
 static const struct l2cap_data client_connect_nval_psm_test_1 = {
 	.client_psm = 0x1001,
 	.expect_err = ECONNREFUSED,
@@ -556,6 +568,17 @@ static const struct l2cap_data l2cap_server_nval_cid_test2 = {
 	.expect_cmd_len = sizeof(l2cap_nval_cfg_rsp),
 };
 
+static const struct l2cap_data l2cap_server_phy_test = {
+	.server_psm = 0x1001,
+	.send_cmd_code = BT_L2CAP_PDU_CONN_REQ,
+	.send_cmd = l2cap_connect_req,
+	.send_cmd_len = sizeof(l2cap_connect_req),
+	.expect_cmd_code = BT_L2CAP_PDU_CONN_RSP,
+	.phys = (BT_PHY_BR_1M_1SLOT |
+	BT_PHY_EDR_2M_1SLOT | BT_PHY_EDR_2M_3SLOT | BT_PHY_EDR_2M_5SLOT |
+	BT_PHY_EDR_3M_1SLOT | BT_PHY_EDR_3M_3SLOT | BT_PHY_EDR_3M_5SLOT),
+};
+
 static const struct l2cap_data le_client_connect_success_test_1 = {
 	.client_psm = 0x0080,
 	.server_psm = 0x0080,
@@ -675,6 +698,12 @@ static const struct l2cap_data le_client_connect_reject_test_2 = {
 	.addr_type = BDADDR_LE_PUBLIC,
 };
 
+static const struct l2cap_data le_client_connect_phy_test_1 = {
+	.client_psm = 0x0080,
+	.server_psm = 0x0080,
+	.phys = (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX),
+};
+
 static uint8_t nonexisting_bdaddr[] = {0x00, 0xAA, 0x01, 0x02, 0x03, 0x00};
 static const struct l2cap_data le_client_close_socket_test_1 = {
 	.client_psm = 0x0080,
@@ -752,6 +781,17 @@ static const struct l2cap_data le_server_nval_scid_test = {
 	.expect_cmd_len = sizeof(nval_le_connect_rsp),
 };
 
+static const struct l2cap_data le_server_phy_test = {
+	.server_psm = 0x0080,
+	.send_cmd_code = BT_L2CAP_PDU_LE_CONN_REQ,
+	.send_cmd = le_connect_req,
+	.send_cmd_len = sizeof(le_connect_req),
+	.expect_cmd_code = BT_L2CAP_PDU_LE_CONN_RSP,
+	.expect_cmd = le_connect_rsp,
+	.expect_cmd_len = sizeof(le_connect_rsp),
+	.phys = (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX),
+};
+
 static const uint8_t ecred_connect_req[] = {	0x80, 0x00, /* PSM */
 						0x40, 0x00, /* MTU */
 						0x40, 0x00, /* MPS */
@@ -810,6 +850,17 @@ static const struct l2cap_data ext_flowctl_server_nval_scid_test = {
 	.expect_cmd_len = sizeof(nval_ecred_connect_rsp),
 };
 
+static const struct l2cap_data ext_flowctl_server_phy_test = {
+	.server_psm = 0x0080,
+	.send_cmd_code = BT_L2CAP_PDU_ECRED_CONN_REQ,
+	.send_cmd = ecred_connect_req,
+	.send_cmd_len = sizeof(ecred_connect_req),
+	.expect_cmd_code = BT_L2CAP_PDU_ECRED_CONN_RSP,
+	.expect_cmd = ecred_connect_rsp,
+	.expect_cmd_len = sizeof(ecred_connect_rsp),
+	.phys = (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX),
+};
+
 static const struct l2cap_data le_att_client_connect_success_test_1 = {
 	.cid = 0x0004,
 	.sec_level = BT_SECURITY_LOW,
@@ -936,6 +987,13 @@ static const struct l2cap_data ext_flowctl_client_2_close_1 = {
 	.close_1 = true,
 };
 
+static const struct l2cap_data ext_flowctl_client_connect_phy_test_1 = {
+	.client_psm = 0x0080,
+	.server_psm = 0x0080,
+	.mode = BT_MODE_EXT_FLOWCTL,
+	.phys = (BT_PHY_LE_1M_TX | BT_PHY_LE_1M_RX),
+};
+
 static void client_cmd_complete(uint16_t opcode, uint8_t status,
 					const void *param, uint8_t len,
 					void *user_data)
@@ -1384,6 +1442,28 @@ static bool check_mtu(struct test_data *data, int sk)
 	return true;
 }
 
+static bool check_phys(struct test_data *data,int sk)
+{
+	const struct l2cap_data *l2data = data->test_data;
+	socklen_t len;
+
+	len = sizeof(data->phys);
+	data->phys = 0;
+
+	if (getsockopt(sk, SOL_BLUETOOTH, BT_PHY, &data->phys, &len) < 0) {
+		tester_warn("getsockopt(BT_PHY): %s (%d)",
+				strerror(errno), errno);
+		return false;
+	}
+
+	if (l2data->phys && l2data->phys != data->phys) {
+		tester_warn("phys 0x%08x != 0x%08x", l2data->phys, data->phys);
+		return false;
+	}
+
+	return true;
+}
+
 static gboolean recv_errqueue(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -1559,6 +1639,11 @@ static gboolean l2cap_connect_cb(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
+	if (!check_phys(data, sk)) {
+		tester_test_failed();
+		return FALSE;
+	}
+
 	if (l2data->read_data) {
 		l2cap_read_data(data, io, data->dcid);
 		return FALSE;
@@ -2279,6 +2364,11 @@ static gboolean l2cap_accept_cb(GIOChannel *io, GIOCondition cond,
 		return FALSE;
 	}
 
+	if (!check_phys(data, sk)) {
+		tester_test_failed();
+		return FALSE;
+	}
+
 	if (l2data->read_data) {
 		l2cap_read_data(data, io, data->dcid);
 		return FALSE;
@@ -2628,6 +2718,10 @@ int main(int argc, char *argv[])
 					&client_connect_shut_wr_success_test,
 					setup_powered_client, test_connect);
 
+	test_l2cap_bredr("L2CAP BR/EDR Client - PHY",
+					&client_connect_phy_test_1,
+					setup_powered_client, test_connect);
+
 	test_l2cap_bredr("L2CAP BR/EDR Server - Success",
 					&l2cap_server_success_test,
 					setup_powered_server, test_server);
@@ -2664,6 +2758,9 @@ int main(int argc, char *argv[])
 	test_l2cap_bredr("L2CAP BR/EDR Server - Invalid Config CID",
 				&l2cap_server_nval_cid_test2,
 				setup_powered_server, test_server);
+	test_l2cap_bredr("L2CAP BR/EDR Server - PHY",
+				&l2cap_server_phy_test,
+				setup_powered_server, test_server);
 
 	test_l2cap_bredr("L2CAP BR/EDR Ethtool Get Ts Info - Success", NULL,
 			setup_powered_server, test_l2cap_ethtool_get_ts_info);
@@ -2710,6 +2807,9 @@ int main(int argc, char *argv[])
 	test_l2cap_bredr("L2CAP LE Client - Connection Reject",
 				&le_client_connect_reject_test_2,
 				setup_powered_client, test_connect_reject);
+	test_l2cap_le("L2CAP LE Client - PHY",
+				&le_client_connect_phy_test_1,
+				setup_powered_client, test_connect);
 
 	test_l2cap_le("L2CAP LE Client - Close socket 1",
 				&le_client_close_socket_test_1,
@@ -2738,7 +2838,8 @@ int main(int argc, char *argv[])
 					setup_powered_server, test_server);
 	test_l2cap_le("L2CAP LE Server - Nval SCID", &le_server_nval_scid_test,
 					setup_powered_server, test_server);
-
+	test_l2cap_le("L2CAP LE Server - PHY", &le_server_phy_test,
+					setup_powered_server, test_server);
 
 	test_l2cap_le("L2CAP Ext-Flowctl Client - Success",
 				&ext_flowctl_client_connect_success_test_1,
@@ -2769,12 +2870,19 @@ int main(int argc, char *argv[])
 				setup_powered_client,
 				test_connect_2);
 
+	test_l2cap_le("L2CAP Ext-Flowctl Client - PHY",
+				&ext_flowctl_client_connect_phy_test_1,
+				setup_powered_client, test_connect);
+
 	test_l2cap_le("L2CAP Ext-Flowctl Server - Success",
 				&ext_flowctl_server_success_test,
 				setup_powered_server, test_server);
 	test_l2cap_le("L2CAP Ext-Flowctl Server - Nval SCID",
 				&ext_flowctl_server_nval_scid_test,
 				setup_powered_server, test_server);
+	test_l2cap_le("L2CAP Ext-Flowctl Server - PHY",
+				&ext_flowctl_server_phy_test,
+				setup_powered_server, test_server);
 
 	test_l2cap_le("L2CAP LE ATT Client - Success",
 				&le_att_client_connect_success_test_1,
-- 
2.52.0


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

* RE: [BlueZ,v1] l2cap-test: Add tests for BT_PHY
  2025-12-10 20:49 [PATCH BlueZ v1] l2cap-test: Add tests for BT_PHY Luiz Augusto von Dentz
@ 2025-12-10 21:46 ` bluez.test.bot
  2025-12-11 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-12-10 21:46 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1032100

---Test result---

Test Summary:
CheckPatch                    PENDING   0.39 seconds
GitLint                       PENDING   0.44 seconds
BuildEll                      PASS      17.88 seconds
BluezMake                     PASS      651.77 seconds
MakeCheck                     PASS      21.95 seconds
MakeDistcheck                 PASS      225.70 seconds
CheckValgrind                 PASS      294.18 seconds
CheckSmatch                   PASS      327.84 seconds
bluezmakeextell               PASS      174.61 seconds
IncrementalBuild              PENDING   0.41 seconds
ScanBuild                     PASS      997.89 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v1] l2cap-test: Add tests for BT_PHY
  2025-12-10 20:49 [PATCH BlueZ v1] l2cap-test: Add tests for BT_PHY Luiz Augusto von Dentz
  2025-12-10 21:46 ` [BlueZ,v1] " bluez.test.bot
@ 2025-12-11 17:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2025-12-11 17:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 10 Dec 2025 15:49:52 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds the following tests that uses BT_PHY to retrieve the ACL/LE
> connection supported PHYs:
> 
> L2CAP BR/EDR Client - PHY
> L2CAP BR/EDR Server - PHY
> L2CAP LE Client - PHY
> L2CAP LE Server - PHY
> L2CAP Ext-Flowctl Client - PHY
> L2CAP Ext-Flowctl Server - PHY
> 
> [...]

Here is the summary with links:
  - [BlueZ,v1] l2cap-test: Add tests for BT_PHY
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e83c6cf125cd

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-12-11 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 20:49 [PATCH BlueZ v1] l2cap-test: Add tests for BT_PHY Luiz Augusto von Dentz
2025-12-10 21:46 ` [BlueZ,v1] " bluez.test.bot
2025-12-11 17:50 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).