]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/vkms: Add KUnit test scaffolding
authorJosé Expósito <jose.exposito89@gmail.com>
Tue, 18 Feb 2025 10:12:03 +0000 (11:12 +0100)
committerMaxime Ripard <mripard@kernel.org>
Fri, 7 Mar 2025 09:58:20 +0000 (10:58 +0100)
Add the required boilerplate to start creating KUnit test.

To run the tests:

    $ ./tools/testing/kunit/kunit.py run \
      --kunitconfig=drivers/gpu/drm/vkms/tests

Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Co-developed-by: Arthur Grillo <arthurgrillo@riseup.net>
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
Co-developed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250218101214.5790-4-jose.exposito89@gmail.com
Signed-off-by: Maxime Ripard <mripard@kernel.org>
drivers/gpu/drm/vkms/Kconfig
drivers/gpu/drm/vkms/Makefile
drivers/gpu/drm/vkms/tests/.kunitconfig [new file with mode: 0644]
drivers/gpu/drm/vkms/tests/Makefile [new file with mode: 0644]
drivers/gpu/drm/vkms/tests/vkms_config_test.c [new file with mode: 0644]

index 9def079f685bd30e1df3e4082e4818e402395391..3c02f928ffe6bbe9494676fc65a94fbb1c44d5e3 100644 (file)
@@ -14,3 +14,18 @@ config DRM_VKMS
          a VKMS.
 
          If M is selected the module will be called vkms.
+
+config DRM_VKMS_KUNIT_TEST
+       tristate "KUnit tests for VKMS" if !KUNIT_ALL_TESTS
+       depends on DRM_VKMS && KUNIT
+       default KUNIT_ALL_TESTS
+       help
+         This builds unit tests for VKMS. This option is not useful for
+         distributions or general kernels, but only for kernel
+         developers working on VKMS.
+
+         For more information on KUnit and unit tests in general,
+         please refer to the KUnit documentation in
+         Documentation/dev-tools/kunit/.
+
+         If in doubt, say "N".
index 6b0615c424f2e4e6c7dcf45c3b9bf7d7f01326f8..c23eee2f3df44b5de5ebf7bfa6214d9f9a0f7e29 100644 (file)
@@ -10,3 +10,4 @@ vkms-y := \
        vkms_connector.o
 
 obj-$(CONFIG_DRM_VKMS) += vkms.o
+obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/
diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig
new file mode 100644 (file)
index 0000000..6a2d870
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_KUNIT=y
+CONFIG_DRM=y
+CONFIG_DRM_VKMS=y
+CONFIG_DRM_VKMS_KUNIT_TEST=y
diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile
new file mode 100644 (file)
index 0000000..9ded37b
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms_config_test.o
diff --git a/drivers/gpu/drm/vkms/tests/vkms_config_test.c b/drivers/gpu/drm/vkms/tests/vkms_config_test.c
new file mode 100644 (file)
index 0000000..1177e62
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <kunit/test.h>
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+static struct kunit_case vkms_config_test_cases[] = {
+       {}
+};
+
+static struct kunit_suite vkms_config_test_suite = {
+       .name = "vkms-config",
+       .test_cases = vkms_config_test_cases,
+};
+
+kunit_test_suite(vkms_config_test_suite);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Kunit test for vkms config utility");