All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian <seb.witt@googlemail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Sebastian <seb.witt@googlemail.com>
Subject: [PATCH v3 6/6] unit/test-hog: Add tests for long Report Map
Date: Thu,  3 Dec 2026 16:34:08 +0100	[thread overview]
Message-ID: <20261203153408.31769-7-seb.witt@googlemail.com> (raw)
In-Reply-To: <20261203153408.31769-1-seb.witt@googlemail.com>

Check that a Report Map longer than 512 octets is read in full when
bt_hog_set_long_report_map is enabled, and truncated to 512 octets
otherwise.
---
 unit/test-hog.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/unit/test-hog.c b/unit/test-hog.c
index 969e02f44..be6952984 100644
--- a/unit/test-hog.c
+++ b/unit/test-hog.c
@@ -99,6 +99,12 @@ struct test_config {
 	uint8_t mode[2];
 	/* Number of HID SCI Mode notifications per mode */
 	unsigned int notifications;
+	/* Whether to accept a Report Map longer than 512 octets, and the
+	 * length of the Report Map the uHID device is expected to be created
+	 * with if not REPORT_MAP_LEN.
+	 */
+	bool long_report_map;
+	size_t report_map_len;
 	/* uHID event expected after the action */
 	uint32_t uhid_type;
 	const uint8_t *uhid_data;
@@ -310,7 +316,9 @@ static bool uhid_read(struct io *io, void *user_data)
 		g_assert_cmpint(ev.u.create2.product, ==, 0x0001);
 		g_assert_cmpint(ev.u.create2.version, ==, 0x0001);
 		g_assert_cmpint(ev.u.create2.bus, ==, BUS_BLUETOOTH);
-		g_assert_cmpint(ev.u.create2.rd_size, ==, REPORT_MAP_LEN);
+		g_assert_cmpint(ev.u.create2.rd_size, ==,
+				data->cfg->report_map_len ?
+				data->cfg->report_map_len : REPORT_MAP_LEN);
 
 		uhid_send(data, UHID_START, 0);
 
@@ -384,6 +392,7 @@ static void test_hog(const void *user_data)
 
 	bt_hog_set_debug(data->hog, print_debug, "bt_hog: ", NULL);
 	bt_hog_set_sci_mode_callback(data->hog, sci_mode_cb, data);
+	bt_hog_set_long_report_map(data->hog, data->cfg->long_report_map);
 
 	g_assert(bt_hog_attach(data->hog, data->client));
 }
@@ -524,6 +533,56 @@ static void test_teardown(const void *user_data)
 	IOV_DATA(0x0c, 0x05, 0x00, 0x3f, 0x00), \
 	IOV_DATA(0x0d, REPORT_MAP_2)
 
+/* A Report Map of 600 octets, longer than the 512 octets an attribute
+ * value may have, read in chunks of HOG_GATT_CLIENT_MTU - 1 octets.
+ */
+#define IOV_ARRAY(array) \
+	{ .iov_base = (void *) array, .iov_len = sizeof(array) }
+
+static const uint8_t long_map_read_rsp[HOG_GATT_CLIENT_MTU] = {
+	0x0b, [1 ... HOG_GATT_CLIENT_MTU - 1] = 0x01
+};
+static const uint8_t long_map_blob_rsp[HOG_GATT_CLIENT_MTU] = {
+	0x0d, [1 ... HOG_GATT_CLIENT_MTU - 1] = 0x01
+};
+static const uint8_t long_map_last_blob_rsp[34] = { 0x0d, [1 ... 33] = 0x01 };
+
+#define READ_LONG_MAP_BLOB(offset...) \
+	IOV_DATA(0x0c, 0x05, 0x00, offset), \
+	IOV_ARRAY(long_map_blob_rsp)
+
+/* Truncated to 512 octets, once 504 octets are read */
+#define READ_LONG_REPORT_MAP_512 \
+	IOV_DATA(0x0a, 0x05, 0x00), \
+	IOV_ARRAY(long_map_read_rsp), \
+	READ_LONG_MAP_BLOB(0x3f, 0x00), \
+	READ_LONG_MAP_BLOB(0x7e, 0x00), \
+	READ_LONG_MAP_BLOB(0xbd, 0x00), \
+	READ_LONG_MAP_BLOB(0xfc, 0x00), \
+	READ_LONG_MAP_BLOB(0x3b, 0x01), \
+	READ_LONG_MAP_BLOB(0x7a, 0x01), \
+	READ_LONG_MAP_BLOB(0xb9, 0x01), \
+	READ_LONG_MAP_BLOB(0xf8, 0x01)
+
+#define READ_LONG_REPORT_MAP_600 \
+	READ_LONG_REPORT_MAP_512, \
+	IOV_DATA(0x0c, 0x05, 0x00, 0x37, 0x02), \
+	IOV_ARRAY(long_map_last_blob_rsp)
+
+#define LONG_MAP_ATTACH(read_report_map...) \
+	READ_PROTO_MODE, \
+	read_report_map, \
+	READ_EXT_REPORT_REF, \
+	READ_INFO, \
+	READ_INPUT, \
+	READ_INPUT_REF, \
+	READ_OUTPUT, \
+	READ_OUTPUT_REF, \
+	READ_FEATURE, \
+	READ_FEATURE_REF, \
+	READ_INPUT_CCC, \
+	ENABLE_INPUT_CCC
+
 /* The uHID device is created once every request is complete */
 #define ATTACH \
 	READ_PROTO_MODE, \
@@ -827,6 +886,19 @@ static const struct test_config cfg_attach = {
 	.creates = 1,
 };
 
+static const struct test_config cfg_long_report_map = {
+	.action = ACT_NONE,
+	.creates = 1,
+	.long_report_map = true,
+	.report_map_len = 600,
+};
+
+static const struct test_config cfg_long_report_map_disabled = {
+	.action = ACT_NONE,
+	.creates = 1,
+	.report_map_len = 512,
+};
+
 static const struct test_config cfg_multi_attach = {
 	.action = ACT_NONE,
 	.creates = 2,
@@ -1104,6 +1176,11 @@ int main(int argc, char *argv[])
 			NOTIFY(0x0c, INPUT_REPORT));
 
 	/* Characteristic GGIT, the discovery being done by bt_gatt_client */
+	define_test("/hog/long-report-map", setup_basic, &cfg_long_report_map,
+			LONG_MAP_ATTACH(READ_LONG_REPORT_MAP_600));
+	define_test("/hog/long-report-map/disabled", setup_basic,
+			&cfg_long_report_map_disabled,
+			LONG_MAP_ATTACH(READ_LONG_REPORT_MAP_512));
 	define_test("HOGP/RH/CGGIT/CHA/BV-01-C [Characteristic GGIT - Report "
 			"Map - RH]",
 			setup_basic, &cfg_attach,
-- 
2.56.1


  parent reply	other threads:[~2026-12-03 15:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CABBYNZ+GNO-eVNC5B_4SqCdHOE+OHmXUaW0NwStd_BsbUzx35A@mail.gmail.com>
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
2026-11-30 20:45   ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-12-01  0:02     ` Accept HoG Report Map longer than 512 octets bluez.test.bot
2026-12-02 16:13       ` Luiz Augusto von Dentz
2026-12-03 18:16         ` Sebastian Witt
2026-11-30 20:45   ` [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input] Sebastian
2026-11-30 20:45   ` [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map Sebastian
2026-11-30 20:45   ` [PATCH v2 4/4] input/hog: Accept Report Map longer than 512 octets Sebastian
2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian
2026-12-03 15:34   ` [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-12-03 17:56     ` Accept HoG Report Map longer than 512 octets bluez.test.bot
2026-12-03 15:34   ` [PATCH v3 2/6] main.conf: Add LongReportMap option to [Input] Sebastian
2026-12-03 15:34   ` [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map Sebastian
2026-12-03 15:34   ` [PATCH v3 4/6] input/hog: Accept Report Map longer than 512 octets Sebastian
2026-12-03 15:34   ` [PATCH v3 5/6] unit/test-gatt: Add tests for long reads beyond " Sebastian
2026-12-03 15:34   ` Sebastian [this message]
2026-12-03 20:30   ` [PATCH v3 0/6] Accept HoG Report Map longer than " patchwork-bot+bluetooth

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=20261203153408.31769-7-seb.witt@googlemail.com \
    --to=seb.witt@googlemail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.