* [PATCH] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()
@ 2023-11-10 11:03 Dipam Turkar
2023-11-10 14:18 ` Maxime Ripard
0 siblings, 1 reply; 2+ messages in thread
From: Dipam Turkar @ 2023-11-10 11:03 UTC (permalink / raw)
To: maarten.lankhorst
Cc: mripard, tzimmermann, airlied, daniel, mairacanal, javierm,
arthurgrillo, dri-devel, linux-kernel, Dipam Turkar
Introduce unit tests for the drm_mode_create_dvi_i_properties() function to ensure
the proper creation of DVI-I specific connector properties.
Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
---
drivers/gpu/drm/tests/drm_connector_test.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index c66aa2dc8d9d..aad63839b5e5 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -4,6 +4,9 @@
*/
#include <drm/drm_connector.h>
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_kunit_helpers.h>
#include <kunit/test.h>
@@ -58,10 +61,27 @@ static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test)
KUNIT_EXPECT_LT(test, ret, 0);
};
+static void drm_test_mode_create_dvi_i_properties(struct kunit *test)
+{
+ struct drm_device *drm;
+ struct device *dev;
+
+ dev = drm_kunit_helper_alloc_device(test);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
+
+ KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_select_subconnector_property);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_subconnector_property);
+}
+
static struct kunit_case drm_get_tv_mode_from_name_tests[] = {
KUNIT_CASE_PARAM(drm_test_get_tv_mode_from_name_valid,
drm_get_tv_mode_from_name_valid_gen_params),
KUNIT_CASE(drm_test_get_tv_mode_from_name_truncated),
+ KUNIT_CASE(drm_test_mode_create_dvi_i_properties),
{ }
};
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()
2023-11-10 11:03 [PATCH] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties() Dipam Turkar
@ 2023-11-10 14:18 ` Maxime Ripard
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Ripard @ 2023-11-10 14:18 UTC (permalink / raw)
To: Dipam Turkar
Cc: maarten.lankhorst, tzimmermann, airlied, daniel, mairacanal,
javierm, arthurgrillo, dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2466 bytes --]
Hi,
On Fri, Nov 10, 2023 at 04:33:23PM +0530, Dipam Turkar wrote:
> Introduce unit tests for the drm_mode_create_dvi_i_properties() function to ensure
> the proper creation of DVI-I specific connector properties.
>
> Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
> ---
> drivers/gpu/drm/tests/drm_connector_test.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
> index c66aa2dc8d9d..aad63839b5e5 100644
> --- a/drivers/gpu/drm/tests/drm_connector_test.c
> +++ b/drivers/gpu/drm/tests/drm_connector_test.c
> @@ -4,6 +4,9 @@
> */
>
> #include <drm/drm_connector.h>
> +#include <drm/drm_device.h>
> +#include <drm/drm_drv.h>
> +#include <drm/drm_kunit_helpers.h>
>
> #include <kunit/test.h>
>
> @@ -58,10 +61,27 @@ static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test)
> KUNIT_EXPECT_LT(test, ret, 0);
> };
>
> +static void drm_test_mode_create_dvi_i_properties(struct kunit *test)
You should document what this test is checking.
Probably something like:
/*
* Test that drm_mode_create_dvi_i_properties() succeeds and have
* created the DVI-I subconnector and select subconectors properties.
*/
> +{
> + struct drm_device *drm;
> + struct device *dev;
> +
> + dev = drm_kunit_helper_alloc_device(test);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
> +
> + drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
> +
> + KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_select_subconnector_property);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_subconnector_property);
These two should be expectations, not assertions.
> static struct kunit_case drm_get_tv_mode_from_name_tests[] = {
> KUNIT_CASE_PARAM(drm_test_get_tv_mode_from_name_valid,
> drm_get_tv_mode_from_name_valid_gen_params),
> KUNIT_CASE(drm_test_get_tv_mode_from_name_truncated),
> + KUNIT_CASE(drm_test_mode_create_dvi_i_properties),
This test suite is meant to test drm_get_tv_mode_from_name. Please
create a new test suite for the function you're testing.
We should also add a few more tests, like calling it twice will still
return 0 on the second attempt for example.
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-10 19:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 11:03 [PATCH] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties() Dipam Turkar
2023-11-10 14:18 ` Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®