diff mbox series

[BlueZ,v1] test-uhid: Add support for device specific testing

Message ID 20240814151135.725001-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v1] test-uhid: Add support for device specific testing | expand

Commit Message

Luiz Augusto von Dentz Aug. 14, 2024, 3:11 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This enables device specific testing and switch to run
bt_uhid_new_default when running as root so the actual kernel driver is
used:

input: MX Anywhere 3 as /devices/virtual/misc/uhid/0005:046D:B025.0031/input/input86
logitech-hidpp-device 0005:046D:B025.0031: input,hidraw10: BLUETOOTH HID v0.14 Mouse [MX Anywhere 3] on 00:00:00:00:00:00
---
 unit/test-uhid.c | 70 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 66 insertions(+), 4 deletions(-)

Comments

bluez.test.bot@gmail.com Aug. 14, 2024, 5:04 p.m. UTC | #1
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=879680

---Test result---

Test Summary:
CheckPatch                    FAIL      0.64 seconds
GitLint                       FAIL      0.45 seconds
BuildEll                      PASS      25.60 seconds
BluezMake                     PASS      1690.72 seconds
MakeCheck                     FAIL      13.83 seconds
MakeDistcheck                 FAIL      164.01 seconds
CheckValgrind                 FAIL      260.57 seconds
CheckSmatch                   PASS      366.87 seconds
bluezmakeextell               PASS      124.69 seconds
IncrementalBuild              PASS      1496.52 seconds
ScanBuild                     PASS      1066.67 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1] test-uhid: Add support for device specific testing
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#95: 
input: MX Anywhere 3 as /devices/virtual/misc/uhid/0005:046D:B025.0031/input/input86

/github/workspace/src/src/13763634.patch total: 0 errors, 1 warnings, 127 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13763634.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v1] test-uhid: Add support for device specific testing

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
9: B1 Line exceeds max length (84>80): "input: MX Anywhere 3 as /devices/virtual/misc/uhid/0005:046D:B025.0031/input/input86"
10: B1 Line exceeds max length (121>80): "logitech-hidpp-device 0005:046D:B025.0031: input,hidraw10: BLUETOOTH HID v0.14 Mouse [MX Anywhere 3] on 00:00:00:00:00:00"
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:

make[3]: *** [Makefile:11764: test-suite.log] Error 1
make[2]: *** [Makefile:11872: check-TESTS] Error 2
make[1]: *** [Makefile:12301: check-am] Error 2
make: *** [Makefile:12303: check] Error 2
##############################
Test: MakeDistcheck - FAIL
Desc: Run Bluez Make Distcheck
Output:

Package cups was not found in the pkg-config search path.
Perhaps you should add the directory containing `cups.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cups' found
make[4]: *** [Makefile:11764: test-suite.log] Error 1
make[3]: *** [Makefile:11872: check-TESTS] Error 2
make[2]: *** [Makefile:12301: check-am] Error 2
make[1]: *** [Makefile:12303: check] Error 2
make: *** [Makefile:12224: distcheck] Error 1
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:

tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12725 | int main(int argc, char *argv[])
      |     ^~~~
make[3]: *** [Makefile:11764: test-suite.log] Error 1
make[2]: *** [Makefile:11872: check-TESTS] Error 2
make[1]: *** [Makefile:12301: check-am] Error 2
make: *** [Makefile:12303: check] Error 2


---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org Aug. 15, 2024, 7:40 p.m. UTC | #2
Hello:

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

On Wed, 14 Aug 2024 11:11:35 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This enables device specific testing and switch to run
> bt_uhid_new_default when running as root so the actual kernel driver is
> used:
> 
> input: MX Anywhere 3 as /devices/virtual/misc/uhid/0005:046D:B025.0031/input/input86
> logitech-hidpp-device 0005:046D:B025.0031: input,hidraw10: BLUETOOTH HID v0.14 Mouse [MX Anywhere 3] on 00:00:00:00:00:00
> 
> [...]

Here is the summary with links:
  - [BlueZ,v1] test-uhid: Add support for device specific testing
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3b7f4b4d3c83

You are awesome, thank you!
diff mbox series

Patch

diff --git a/unit/test-uhid.c b/unit/test-uhid.c
index 573da318d480..2765feb72b06 100644
--- a/unit/test-uhid.c
+++ b/unit/test-uhid.c
@@ -33,8 +33,19 @@  struct test_pdu {
 	size_t size;
 };
 
+struct test_device {
+	const char *name;
+	uint32_t vendor;
+	uint32_t product;
+	uint32_t version;
+	uint32_t country;
+	uint8_t type;
+	struct iovec map;
+};
+
 struct test_data {
 	char *test_name;
+	struct test_device *test_device;
 	struct test_pdu *pdu_list;
 };
 
@@ -54,17 +65,21 @@  struct context {
 		.size = sizeof(*args),				\
 	}
 
-#define define_test(name, function, args...)				\
+#define define_test_device(name, function, device, args...)		\
 	do {								\
 		const struct test_pdu pdus[] = {			\
 			args, { }					\
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
+		data.test_device = device;				\
 		data.pdu_list = util_memdup(pdus, sizeof(pdus));	\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
+#define define_test(name, function, args...)			\
+	define_test_device(name, function, NULL, args)
+
 static void test_debug(const char *str, void *user_data)
 {
 	const char *prefix = user_data;
@@ -174,8 +189,20 @@  static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 static struct context *create_context(gconstpointer data)
 {
 	struct context *context = g_new0(struct context, 1);
+	const struct test_data *test_data = data;
 	GIOChannel *channel;
 	int err, sv[2];
+	uid_t uid = getuid();
+
+	context->data = data;
+
+	/* Device testings requires extra permissions in order to be able to
+	 * create devices.
+	 */
+	if (test_data->test_device && !uid) {
+		context->uhid = bt_uhid_new_default();
+		return context;
+	}
 
 	err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
 	g_assert(err == 0);
@@ -197,7 +224,6 @@  static struct context *create_context(gconstpointer data)
 	g_io_channel_unref(channel);
 
 	context->fd = sv[1];
-	context->data = data;
 
 	return context;
 }
@@ -229,10 +255,20 @@  static const struct uhid_event ev_feature = {
 static void test_client(gconstpointer data)
 {
 	struct context *context = create_context(data);
+	struct test_device *device = context->data->test_device;
 	int err;
 
-	err = bt_uhid_create(context->uhid, "", NULL, NULL, 0, 0, 0, 0,
-				BT_UHID_NONE, NULL, 0);
+	if (device)
+		err = bt_uhid_create(context->uhid, device->name,
+					BDADDR_ANY, BDADDR_ANY,
+					device->vendor, device->product,
+					device->version, device->country,
+					device->type, device->map.iov_base,
+					device->map.iov_len);
+	else
+		err = bt_uhid_create(context->uhid, "", NULL, NULL, 0, 0, 0, 0,
+					BT_UHID_NONE, NULL, 0);
+
 	if (err < 0) {
 		tester_debug("create failed: %s\n", strerror(-err));
 		tester_test_failed();
@@ -284,6 +320,29 @@  static void test_server(gconstpointer data)
 	g_idle_add(send_pdu, context);
 }
 
+
+static struct test_device mx_anywhere_3 = {
+	.name = "MX Anywhere 3",
+	.vendor = 0x46D,
+	.product = 0xB025,
+	.version = 0x14,
+	.country = 0x00,
+	.type = BT_UHID_MOUSE,
+	.map = UTIL_IOV_INIT(0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x85, 0x02,
+				0x09, 0x01, 0xA1, 0x00, 0x95, 0x10, 0x75, 0x01,
+				0x15, 0x00, 0x25, 0x01, 0x05, 0x09, 0x19, 0x01,
+				0x29, 0x10, 0x81, 0x02, 0x05, 0x01, 0x16, 0x01,
+				0xF8, 0x26, 0xFF, 0x07, 0x75, 0x0C, 0x95, 0x02,
+				0x09, 0x30, 0x09, 0x31, 0x81, 0x06, 0x15, 0x81,
+				0x25, 0x7F, 0x75, 0x08, 0x95, 0x01, 0x09, 0x38,
+				0x81, 0x06, 0x95, 0x01, 0x05, 0x0C, 0x0A, 0x38,
+				0x02, 0x81, 0x06, 0xC0, 0xC0, 0x06, 0x43, 0xFF,
+				0x0A, 0x02, 0x02, 0xA1, 0x01, 0x85, 0x11, 0x75,
+				0x08, 0x95, 0x13, 0x15, 0x00, 0x26, 0xFF, 0x00,
+				0x09, 0x02, 0x81, 0x00, 0x09, 0x02, 0x91, 0x00,
+				0xC0),
+};
+
 int main(int argc, char *argv[])
 {
 	tester_init(&argc, &argv);
@@ -297,5 +356,8 @@  int main(int argc, char *argv[])
 	define_test("/uhid/event/output", test_server, event(&ev_output));
 	define_test("/uhid/event/feature", test_server, event(&ev_feature));
 
+	define_test_device("/uhid/device/mx_anywhere_3", test_client,
+					&mx_anywhere_3, event(&ev_create));
+
 	return tester_run();
 }