Skip to content

Commit 5d4ae0b

Browse files
Wer-Wolfij-intel
authored andcommitted
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: 0e1a814 ("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>
1 parent 8164a14 commit 5d4ae0b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/platform/wmi/tests/string_kunit.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ static void wmi_string_to_utf8s_oversized_test(struct kunit *test)
228228
KUNIT_EXPECT_MEMEQ(test, result, test_utf8_string, sizeof(test_utf8_string));
229229
}
230230

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+
231248
static void wmi_string_to_utf8s_invalid_test(struct kunit *test)
232249
{
233250
u8 result[sizeof(invalid_test_utf8_string)];
@@ -261,6 +278,7 @@ static struct kunit_case wmi_string_test_cases[] = {
261278
KUNIT_CASE(wmi_string_to_utf8s_padded_test),
262279
KUNIT_CASE(wmi_string_from_utf8s_padded_test),
263280
KUNIT_CASE(wmi_string_to_utf8s_oversized_test),
281+
KUNIT_CASE(wmi_string_from_utf8s_oversized_test),
264282
KUNIT_CASE(wmi_string_to_utf8s_invalid_test),
265283
KUNIT_CASE(wmi_string_from_utf8s_invalid_test),
266284
{}

0 commit comments

Comments
 (0)