From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: Hans de Goede <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux@weissschuh.net, Dell.Client.Kernel@dell.com,
corbet@lwn.net, linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 4/9] platform/wmi: Add kunit test for the string conversion code
Date: Mon, 12 Jan 2026 18:34:05 +0200 (EET) [thread overview]
Message-ID: <c8c399b0-7eda-a12a-61b4-9777e07c98ae@linux.intel.com> (raw)
In-Reply-To: <20260109214619.7289-5-W_Armin@gmx.de>
On Fri, 9 Jan 2026, Armin Wolf wrote:
> The string conversion frunctions provided by the WMI driver core
> have no dependencies on the remaining WMI API, making them suitable
> for unit tests.
>
> Implement such a unit test using kunit. Those unit tests verify that
> converting between WMI strings and UTF8 strings works as expected.
> They also verify that edge cases are handled correctly.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> drivers/platform/wmi/tests/Kconfig | 11 +
> drivers/platform/wmi/tests/Makefile | 3 +
> drivers/platform/wmi/tests/string_kunit.c | 278 ++++++++++++++++++++++
> 3 files changed, 292 insertions(+)
> create mode 100644 drivers/platform/wmi/tests/string_kunit.c
>
> diff --git a/drivers/platform/wmi/tests/Kconfig b/drivers/platform/wmi/tests/Kconfig
> index efcbcb51c251..f7f0f3c540f5 100644
> --- a/drivers/platform/wmi/tests/Kconfig
> +++ b/drivers/platform/wmi/tests/Kconfig
> @@ -14,3 +14,14 @@ config ACPI_WMI_MARSHALLING_KUNIT_TEST
> to the KUnit documentation in Documentation/dev-tools/kunit/.
>
> If unsure, say N.
> +
> +config ACPI_WMI_STRING_KUNIT_TEST
> + tristate "KUnit Test for ACPI-WMI string conversion" if !KUNIT_ALL_TESTS
> + depends on KUNIT
> + default KUNIT_ALL_TESTS
> + help
> + This builds unit tests for the ACPI-WMI string conversion code.
> + For more information on KUnit and unit tests in general, please refer
> + to the KUnit documentation in Documentation/dev-tools/kunit/.
> +
> + If unsure, say N.
> diff --git a/drivers/platform/wmi/tests/Makefile b/drivers/platform/wmi/tests/Makefile
> index 252c3125353a..62c438e26259 100644
> --- a/drivers/platform/wmi/tests/Makefile
> +++ b/drivers/platform/wmi/tests/Makefile
> @@ -6,3 +6,6 @@
>
> wmi_marshalling_kunit-y := marshalling_kunit.o
> obj-$(CONFIG_ACPI_WMI_MARSHALLING_KUNIT_TEST) += wmi_marshalling_kunit.o
> +
> +wmi_string_kunit-y := string_kunit.o
> +obj-$(CONFIG_ACPI_WMI_STRING_KUNIT_TEST) += wmi_string_kunit.o
> diff --git a/drivers/platform/wmi/tests/string_kunit.c b/drivers/platform/wmi/tests/string_kunit.c
> new file mode 100644
> index 000000000000..9aa3ffa85090
> --- /dev/null
> +++ b/drivers/platform/wmi/tests/string_kunit.c
> @@ -0,0 +1,278 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * KUnit test for the ACPI-WMI string conversion code.
> + *
> + * Copyright (C) 2025 Armin Wolf <W_Armin@gmx.de>
> + */
> +
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +#include <linux/wmi.h>
> +
> +#include <kunit/resource.h>
> +#include <kunit/test.h>
> +
> +#include <asm/byteorder.h>
> +
> +struct wmi_string_param {
> + const char *name;
> + const struct wmi_string *wmi_string;
> + /*
> + * Remember that using sizeof() on a struct wmi_string will
> + * always return a size of two bytes due to the flexible
> + * array member!
> + */
> + size_t wmi_string_length;
> + const u8 *utf8_string;
> + size_t utf8_string_length;
> +};
> +
> +#define TEST_WMI_STRING_LENGTH 12
> +
> +static const struct wmi_string test_wmi_string = {
> + .length = cpu_to_le16(10),
> + .chars = {
> + cpu_to_le16(u'T'),
I've applied this to for-next and intend to keep these there but FYI these
trigger sparse errors. I don't know if they're fixable or not with
reasonable effort on kernel side.
$ sparse --version
0.6.4 (Debian: 0.6.4-3)
--
i.
next prev parent reply other threads:[~2026-01-12 16:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 21:46 [PATCH v3 0/9] platform/wmi: Introduce marshalling support Armin Wolf
2026-01-09 21:46 ` [PATCH v3 1/9] " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 2/9] platform/wmi: Add kunit test for the marshalling code Armin Wolf
2026-01-09 21:46 ` [PATCH v3 3/9] platform/wmi: Add helper functions for WMI string conversions Armin Wolf
2026-01-09 21:46 ` [PATCH v3 4/9] platform/wmi: Add kunit test for the string conversion code Armin Wolf
2026-01-12 16:34 ` Ilpo Järvinen [this message]
2026-01-12 17:59 ` Armin Wolf
2026-01-12 18:11 ` Ilpo Järvinen
2026-01-22 23:45 ` Nathan Chancellor
2026-01-23 19:17 ` Armin Wolf
2026-01-09 21:46 ` [PATCH v3 5/9] platform/x86: intel-wmi-sbl-fw-update: Use new buffer-based WMI API Armin Wolf
2026-01-09 21:46 ` [PATCH v3 6/9] platform/x86/intel/wmi: thunderbolt: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 7/9] platform/x86: xiaomi-wmi: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 8/9] platform/x86: wmi-bmof: " Armin Wolf
2026-01-09 21:46 ` [PATCH v3 9/9] platform/wmi: Update driver development guide Armin Wolf
2026-01-12 15:33 ` [PATCH v3 0/9] platform/wmi: Introduce marshalling support Ilpo Järvinen
2026-01-12 18:00 ` Armin Wolf
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=c8c399b0-7eda-a12a-61b4-9777e07c98ae@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=hansg@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=platform-driver-x86@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