Skip to content

Commit 29dfba6

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/wmi: Add kunit test for the marshalling code
The marshalling code used by the WMI driver core is implemented as a separate component, suitable for unit tests. Implmented such a unit test using KUnit. Those unit tests verify that ACPI objects are correctly converted into WMI buffers and that WMI strings are correctly converted into ACPI strings. They also verify that invalid ACPI data (like nested packages) is rejected. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://patch.msgid.link/20260116204116.4030-3-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 015b70a commit 29dfba6

5 files changed

Lines changed: 481 additions & 0 deletions

File tree

drivers/platform/wmi/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ config ACPI_WMI_LEGACY_DEVICE_NAMES
3131
userspace applications but will cause the registration of WMI devices with
3232
the same GUID to fail in some corner cases.
3333

34+
source "drivers/platform/wmi/tests/Kconfig"
35+
3436
endif # ACPI_WMI

drivers/platform/wmi/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66

77
wmi-y := core.o marshalling.o
88
obj-$(CONFIG_ACPI_WMI) += wmi.o
9+
10+
# Unit tests
11+
obj-y += tests/

drivers/platform/wmi/tests/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# ACPI WMI KUnit tests
4+
#
5+
6+
config ACPI_WMI_MARSHALLING_KUNIT_TEST
7+
tristate "KUnit Test for ACPI-WMI marshalling" if !KUNIT_ALL_TESTS
8+
depends on KUNIT
9+
default KUNIT_ALL_TESTS
10+
help
11+
This builds unit tests for the ACPI-WMI marshalling code.
12+
13+
For more information on KUnit and unit tests in general, please refer
14+
to the KUnit documentation in Documentation/dev-tools/kunit/.
15+
16+
If unsure, say N.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# Makefile for linux/drivers/platform/x86/wmi/tests
4+
# ACPI WMI KUnit tests
5+
#
6+
7+
wmi_marshalling_kunit-y := marshalling_kunit.o
8+
obj-$(CONFIG_ACPI_WMI_MARSHALLING_KUNIT_TEST) += wmi_marshalling_kunit.o

0 commit comments

Comments
 (0)