The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] platform/wmi: string-kunit: Add missing oversized string test case
@ 2026-01-23 21:15 Armin Wolf
  2026-01-26 14:30 ` Ilpo Järvinen
  0 siblings, 1 reply; 3+ messages in thread
From: Armin Wolf @ 2026-01-23 21:15 UTC (permalink / raw)
  To: ilpo.jarvinen, hansg; +Cc: nathan, platform-driver-x86, linux-kernel

When compiling the WMI string kunit tests using llvm, the compiler
will issue a warning about "oversized_test_utf8_string" being unused.
This happens because the test case that was supposed to use said
variable was accidentally omitted when adding the kunit tests.

Fix this by adding the aforementioned test case.

Fixes: 0e1a8143e797 ("platform/wmi: Add kunit test for the string conversion code")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/platform-driver-x86/20260122234521.GA413183@ax162/
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/wmi/tests/string_kunit.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/platform/wmi/tests/string_kunit.c b/drivers/platform/wmi/tests/string_kunit.c
index 9aa3ffa85090..117f32ee26a8 100644
--- a/drivers/platform/wmi/tests/string_kunit.c
+++ b/drivers/platform/wmi/tests/string_kunit.c
@@ -228,6 +228,23 @@ static void wmi_string_to_utf8s_oversized_test(struct kunit *test)
 	KUNIT_EXPECT_MEMEQ(test, result, test_utf8_string, sizeof(test_utf8_string));
 }
 
+static void wmi_string_from_utf8s_oversized_test(struct kunit *test)
+{
+	struct wmi_string *result;
+	size_t max_chars;
+	ssize_t ret;
+
+	max_chars = (TEST_WMI_STRING_LENGTH - sizeof(*result)) / 2;
+	result = kunit_kzalloc(test, TEST_WMI_STRING_LENGTH, GFP_KERNEL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, result);
+
+	ret = wmi_string_from_utf8s(result, max_chars, oversized_test_utf8_string,
+				    sizeof(oversized_test_utf8_string));
+
+	KUNIT_EXPECT_EQ(test, ret, sizeof(test_utf8_string) - 1);
+	KUNIT_EXPECT_MEMEQ(test, result, &test_wmi_string, sizeof(test_wmi_string));
+}
+
 static void wmi_string_to_utf8s_invalid_test(struct kunit *test)
 {
 	u8 result[sizeof(invalid_test_utf8_string)];
@@ -261,6 +278,7 @@ static struct kunit_case wmi_string_test_cases[] = {
 	KUNIT_CASE(wmi_string_to_utf8s_padded_test),
 	KUNIT_CASE(wmi_string_from_utf8s_padded_test),
 	KUNIT_CASE(wmi_string_to_utf8s_oversized_test),
+	KUNIT_CASE(wmi_string_from_utf8s_oversized_test),
 	KUNIT_CASE(wmi_string_to_utf8s_invalid_test),
 	KUNIT_CASE(wmi_string_from_utf8s_invalid_test),
 	{}
-- 
2.39.5


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

* Re: [PATCH] platform/wmi: string-kunit: Add missing oversized string test case
  2026-01-23 21:15 [PATCH] platform/wmi: string-kunit: Add missing oversized string test case Armin Wolf
@ 2026-01-26 14:30 ` Ilpo Järvinen
  2026-01-27  5:33   ` Armin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2026-01-26 14:30 UTC (permalink / raw)
  To: hansg, Armin Wolf; +Cc: nathan, platform-driver-x86, linux-kernel

On Fri, 23 Jan 2026 22:15:37 +0100, Armin Wolf wrote:

> When compiling the WMI string kunit tests using llvm, the compiler
> will issue a warning about "oversized_test_utf8_string" being unused.
> This happens because the test case that was supposed to use said
> variable was accidentally omitted when adding the kunit tests.
> 
> Fix this by adding the aforementioned test case.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/wmi: string-kunit: Add missing oversized string test case
      commit: 5d4ae0bffb6eeada6dd16ba52150457ae96c3725

--
 i.


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

* Re: [PATCH] platform/wmi: string-kunit: Add missing oversized string test case
  2026-01-26 14:30 ` Ilpo Järvinen
@ 2026-01-27  5:33   ` Armin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Armin Wolf @ 2026-01-27  5:33 UTC (permalink / raw)
  To: Ilpo Järvinen, hansg; +Cc: nathan, platform-driver-x86, linux-kernel

Am 26.01.26 um 15:30 schrieb Ilpo Järvinen:

> On Fri, 23 Jan 2026 22:15:37 +0100, Armin Wolf wrote:
>
>> When compiling the WMI string kunit tests using llvm, the compiler
>> will issue a warning about "oversized_test_utf8_string" being unused.
>> This happens because the test case that was supposed to use said
>> variable was accidentally omitted when adding the kunit tests.
>>
>> Fix this by adding the aforementioned test case.
>>
>> [...]
>
> Thank you for your contribution, it has been applied to my local
> review-ilpo-next branch. Note it will show up in the public
> platform-drivers-x86/review-ilpo-next branch only once I've pushed my
> local branch there, which might take a while.

Thank you :)

> The list of commits applied:
> [1/1] platform/wmi: string-kunit: Add missing oversized string test case
>        commit: 5d4ae0bffb6eeada6dd16ba52150457ae96c3725
>
> --
>   i.
>

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

end of thread, other threads:[~2026-01-27  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 21:15 [PATCH] platform/wmi: string-kunit: Add missing oversized string test case Armin Wolf
2026-01-26 14:30 ` Ilpo Järvinen
2026-01-27  5:33   ` Armin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox