Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/wmi: string-kunit: Add missing oversized string test case

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>
Link: https://patch.msgid.link/20260123211537.4448-1-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Armin Wolf and committed by
Ilpo Järvinen
5d4ae0bf 8164a14b

+18
+18
drivers/platform/wmi/tests/string_kunit.c
··· 228 228 KUNIT_EXPECT_MEMEQ(test, result, test_utf8_string, sizeof(test_utf8_string)); 229 229 } 230 230 231 + static void wmi_string_from_utf8s_oversized_test(struct kunit *test) 232 + { 233 + struct wmi_string *result; 234 + size_t max_chars; 235 + ssize_t ret; 236 + 237 + max_chars = (TEST_WMI_STRING_LENGTH - sizeof(*result)) / 2; 238 + result = kunit_kzalloc(test, TEST_WMI_STRING_LENGTH, GFP_KERNEL); 239 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, result); 240 + 241 + ret = wmi_string_from_utf8s(result, max_chars, oversized_test_utf8_string, 242 + sizeof(oversized_test_utf8_string)); 243 + 244 + KUNIT_EXPECT_EQ(test, ret, sizeof(test_utf8_string) - 1); 245 + KUNIT_EXPECT_MEMEQ(test, result, &test_wmi_string, sizeof(test_wmi_string)); 246 + } 247 + 231 248 static void wmi_string_to_utf8s_invalid_test(struct kunit *test) 232 249 { 233 250 u8 result[sizeof(invalid_test_utf8_string)]; ··· 278 261 KUNIT_CASE(wmi_string_to_utf8s_padded_test), 279 262 KUNIT_CASE(wmi_string_from_utf8s_padded_test), 280 263 KUNIT_CASE(wmi_string_to_utf8s_oversized_test), 264 + KUNIT_CASE(wmi_string_from_utf8s_oversized_test), 281 265 KUNIT_CASE(wmi_string_to_utf8s_invalid_test), 282 266 KUNIT_CASE(wmi_string_from_utf8s_invalid_test), 283 267 {}