From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796066744; b=ol10pttbAmAK6Vz6fbudve+BedPGLFJzL5+dcTLEm/ZXlDFIhhz5wT58WquVDVxpDx59 sie64txTePRXEQ35jW7uA7lbsEHLtE+2AuQTl0QPFULK6yHEHE7lt0XQDNfN5YYuGt2cz MVdqXRr24ZbjMkk4TesszykSh8weFc9XU9uMg6Z7siFzoR6lhLIprJ6jMWh0u1fS4idoC bEPPRIr/WHviqYA2cMhkvgIZ8zmtlbGggs2OvbTkndBs1mbe9JA/843TzSqRfK/ekKc+e lGkOZ2gnqgx5XlQBHadd70tg2YAXkTX6qwgI3paLHmMWbtJ+En6YbD/tSwQYPsNTu/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796066744; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=4LB8k0UgEakaTIq3djPNvgilZCV3OFMQwWqeJyEh/s4=; b=smWUZPD1zcytTEM93s6ZnyA4UvpwQ1PhtOg2aQfs+2O4g9bhlpYwsluIwvMpyYjyR+cq U7NRbqp8LduWfNJS+ST0oDh0qscff8GHZlESj4l5BB1Wsq4Nd8qsTJQA5dPzrIZn7k6ai Pt3CGTTZFcPhdGh3Kf32ouacO9fLjIrzlztGcHiqaR8uZD3tlRpuIsul/SLSZSexuoT8c cdk8acSQ+604SjNmPWdtXyQDIYYzRx2rT0JIFO6sReo3zcODcPVRZM5uYLRZGQkhfvsXN tldqAXFZlErxSWAtOb8QQrcgvwKIxlFweZ6a7buMkiQ1OMgxdA2xI2bvAUsR07M8Gzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass header.d=googlemail.com header.i=@googlemail.com header.a=rsa-sha256 header.s=20260707 header.b=tr+jfgBo; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1FF0606A329 for ; Mon, 30 Nov 2026 19:25:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E1FF0606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.a=rsa-sha256 header.s=20260707 header.b=tr+jfgBo Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-48e09aa5264so6411311f8f.2 for ; Mon, 30 Nov 2026 11:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20260707; t=1796066742; x=1796671542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4LB8k0UgEakaTIq3djPNvgilZCV3OFMQwWqeJyEh/s4=; b=tr+jfgBoFJsGbNUF7fUXeLaxNHfUzDsRwocA9HbmSkLpc9VW277Co5zFpx9nXChodI 6tah+fXZN2VAorsBk3jGQ+AgOsIeoTIJRGML5l16FUzLGQd605Ty0mRFvuCLVQCniZV4 8l6PjPcYs+MQsRyzImPFBabQUnvk8ukBqYjWednm31d5FnTKEadw3c399fOdgRntnKyd 7iSS6/q8k4l4AhB2npD4eX4vYqmzt8A/oQOYzEl4JUteXssKkyuTYW/K41/TitFk/mme 303uBSmYqWoiizfP2Lprxfn65WgFor6VYGVJppg8c/O4r35mxpJs9hXUFXdVdGCiwW4i QyQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796066742; x=1796671542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4LB8k0UgEakaTIq3djPNvgilZCV3OFMQwWqeJyEh/s4=; b=GTrPeHXyvQbr1z4BzGfNR0FZFouL1q3HNDjIjzA5+tpazYEtuQzzpyFnf4l7Rnm6Z6 Csdf98ZmGJiN7O7nJ3lD2/j4BO33lc2fh4u1v90aaNay3nu41j6Rbybh22W5rHP5dGJw PKwWbo9FOZuYrIrxGoEbgTUEVf+ZqZkbWHNz4LQE+JBQM8DuLVUigb6X8AyrVBRdpvLx 2SfEoOdDzpU0KLOnhWLf0CeK2/OMZwfJB41ergB3A9nPfGDm70kcc6PG76q3aoI+CcW2 vyvgsoj8W7wJcY1p8/jojovMCcTrhYWcSw8Qm4beitjqts64SQfSA8BdwBzMns/c8zBs bOGw== X-Gm-Message-State: APuU4Z+9q8+JE5E+pcuIfSMxuINevjIlq8gp69CcyUu+1Ns1rMdARkjP cpWrRoOK4SJUYqZx3Tg22OAQquna0e1VT/gCGyoFlzdh5Vmlf3LHOJ/3QYS035uNYco= X-Gm-Gg: AZFdTZcT79i4eCHv0qEzN1waaweK3aZ8ylAM3QRkAGgOhygQxQrt0E+g6YbubCh6ltk dmMGl8TvXbFnwh8/L9qMIKuthzPZMLXYEKVNoWmHeGHXK0Q1lLcomXlR1Wz4IhPVH6O4g2qnI3E RMSzgkkOVa0s8QTp4ihV/oL1bX3wg46pcWnc+bCYAuZL3l5dHRIrbikFJiTaqxCpcQtlWcdWUJl wZ9FgowqHJ1BFj/feSlx8xLpnrjqimSVY2B6Dm0OwEK3ThAQzwQFcJITZPDCDq9i7ZZIIeXbIQM //jOBhMHeUFC8ey75+tz3p5Fnw+S9mHb5oGGoJJZkh3JMcmRSDWSq4E0eVzLqLirCj0AC1NOXoT Vp1gT1I/dcFJyqxvcnJ67xL5MDNOKmQnYQfgad4/pX2tK2HLxAAr+pT3Tse7JCFFRW6do9ktemU gTUnGrufrQW55zjDUIhsRgiYCjfC4d4SJvf0pTOs6eV+MVIYxQqNfIpM7xnpKhqvaaOyuX0GyzC W9Y/hqrY+pGnbOkCwO3Gbj3jn94tXN1Xo7TGRbkd8uBuqJpigA+il0AEL97z1TkIyyTYlC32UUN DKqItXcZplg7AiV3UHEye0N2OvTheCD7GWTS/sQLs9Q3uf1/AY/kiwvRdw== X-Received: by 2002:a05:6000:2f87:b0:4a7:1428:13dd with SMTP id ffacd0b85a97d-4abb19c173emr64428460f8f.21.1796066742100; Mon, 30 Nov 2026 11:25:42 -0800 (PST) Received: from sp8 (213-146-237-228.ptr.skytron.de. [213.146.237.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb4341sm65688773f8f.4.2026.11.30.11.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 11:25:41 -0800 (PST) From: Sebastian To: linux-bluetooth@vger.kernel.org Cc: Sebastian , "Claude Opus 5.5" Subject: [PATCH 2/2] unit/test-hog: Add test for the PnP ID Date: Mon, 30 Nov 2026 20:25:21 +0100 Message-ID: <20261130192521.246374-3-seb.witt@googlemail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130192521.246374-1-seb.witt@googlemail.com> References: <20261130192521.246374-1-seb.witt@googlemail.com> X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a HID Device with a Device Information Service, and check the uHID device is created with the vendor, product and version of its PnP ID. Co-Authored-By: Claude Opus 5.5 --- unit/test-hog.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/unit/test-hog.c b/unit/test-hog.c index 969e02f44..ebaa997ed 100644 --- a/unit/test-hog.c +++ b/unit/test-hog.c @@ -64,7 +64,9 @@ * 0x001d Client Characteristic Configuration * 0x001f HID SCI Information (Read) - SCI variant * - * followed by a Battery Service with the Battery Level characteristic. + * followed by a Battery Service with the Battery Level characteristic, the + * PnP ID variant adding a Device Information Service at 0x001f with the + * PnP ID characteristic at 0x0020. * * The Client Characteristic Configuration descriptors following a * characteristic with no other descriptor are not discovered with Find @@ -99,6 +101,10 @@ struct test_config { uint8_t mode[2]; /* Number of HID SCI Mode notifications per mode */ unsigned int notifications; + /* Whether the IDs are expected from the PnP ID, instead of the ones + * HoG is created with. + */ + bool pnp_id; /* uHID event expected after the action */ uint32_t uhid_type; const uint8_t *uhid_data; @@ -306,9 +312,15 @@ static bool uhid_read(struct io *io, void *user_data) if (ev.type == UHID_CREATE2) { g_assert_cmpstr((char *) ev.u.create2.name, ==, "bluez-hog"); - g_assert_cmpint(ev.u.create2.vendor, ==, 0x0002); - g_assert_cmpint(ev.u.create2.product, ==, 0x0001); - g_assert_cmpint(ev.u.create2.version, ==, 0x0001); + if (data->cfg->pnp_id) { + g_assert_cmpint(ev.u.create2.vendor, ==, 0x1234); + g_assert_cmpint(ev.u.create2.product, ==, 0x5678); + g_assert_cmpint(ev.u.create2.version, ==, 0x0100); + } else { + g_assert_cmpint(ev.u.create2.vendor, ==, 0x0002); + 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); @@ -510,6 +522,9 @@ static void test_teardown(const void *user_data) #define READ_OUTPUT_REF READ(0x11, 0x01, 0x02) #define READ_FEATURE READ(0x13, 0x00) #define READ_FEATURE_REF READ(0x14, 0x01, 0x03) +/* PnP ID: USB vendor 0x1234, product 0x5678, version 0x0100 */ +#define READ_PNP_ID READ(0x21, 0x02, 0x34, 0x12, 0x78, 0x56, \ + 0x00, 0x01) #define READ_INPUT_CCC READ(0x0d, 0x00, 0x00) #define ENABLE_INPUT_CCC WRITE(0x0d, 0x01, 0x00) #define READ_SCI_MODE READ(0x1c, 0x00) @@ -637,6 +652,30 @@ static const struct iovec setup_basic[] = { DISC_HID_DESC, }; +/* The basic layout followed by a Device Information Service */ +static const struct iovec setup_pnp_id[] = { + DISC_MTU, + DISC_SR_FEATURES, + IOV_DATA(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28), + IOV_DATA(0x11, 0x06, 0x01, 0x00, 0x1a, 0x00, 0x12, 0x18, 0x1b, + 0x00, 0x1e, 0x00, 0x0f, 0x18, 0x1f, 0x00, 0x21, + 0x00, 0x0a, 0x18), + IOV_DATA(0x10, 0x22, 0x00, 0xff, 0xff, 0x00, 0x28), + IOV_DATA(0x01, 0x10, 0x22, 0x00, 0x0a), + DISC_SECONDARY, + IOV_DATA(0x08, 0x01, 0x00, 0x21, 0x00, 0x02, 0x28), + IOV_DATA(0x01, 0x08, 0x01, 0x00, 0x0a), + IOV_DATA(0x08, 0x01, 0x00, 0x21, 0x00, 0x03, 0x28), + DISC_HID_CHRC_1, + IOV_DATA(0x08, 0x16, 0x00, 0x21, 0x00, 0x03, 0x28), + IOV_DATA(0x09, 0x07, 0x18, 0x00, 0x12, 0x19, 0x00, 0x33, 0x2a, + 0x1c, 0x00, 0x12, 0x1d, 0x00, 0x19, 0x2a, 0x20, + 0x00, 0x02, 0x21, 0x00, 0x50, 0x2a), + IOV_DATA(0x08, 0x21, 0x00, 0x21, 0x00, 0x03, 0x28), + IOV_DATA(0x01, 0x08, 0x21, 0x00, 0x0a), + DISC_HID_DESC, +}; + static const struct iovec setup_sci[] = { DISC_MTU, DISC_SR_FEATURES, @@ -827,6 +866,12 @@ static const struct test_config cfg_attach = { .creates = 1, }; +static const struct test_config cfg_pnp_id_attach = { + .action = ACT_NONE, + .creates = 1, + .pnp_id = true, +}; + static const struct test_config cfg_multi_attach = { .action = ACT_NONE, .creates = 2, @@ -1104,6 +1149,20 @@ int main(int argc, char *argv[]) NOTIFY(0x0c, INPUT_REPORT)); /* Characteristic GGIT, the discovery being done by bt_gatt_client */ + define_test("/hog/pnp-id", setup_pnp_id, &cfg_pnp_id_attach, + 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_PNP_ID, + READ_INPUT_CCC, + ENABLE_INPUT_CCC); define_test("HOGP/RH/CGGIT/CHA/BV-01-C [Characteristic GGIT - Report " "Map - RH]", setup_basic, &cfg_attach, -- 2.56.1