drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()
Subsystems (2)
PATCH 1/1 drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()
Introduce unit tests for the drm_mode_create_dvi_i_properties() function to ensure the proper creation of DVI-I specific connector properties.
--- drivers/gpu/drm/tests/drm_connector_test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/tests/drm_connector_test.c +20 -0
@@ -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), { } };
Signature · 1 line
2.34.1
Maxime Ripard
maintainerHi,
Quoted 23 lines · 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 <[email protected]>--- drivers/gpu/drm/tests/drm_connector_test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/tests/drm_connector_test.c +3
-0@@ -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>
drivers/gpu/drm/tests/drm_connector_test.c static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test) · line 64
Quoted 4 lines
drivers/gpu/drm/tests/drm_connector_test.c +1
-0@@ -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. */
drivers/gpu/drm/tests/drm_connector_test.c static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test) · line 77
Quoted 13 lines
drivers/gpu/drm/tests/drm_connector_test.c +13
-0+{ +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.
drivers/gpu/drm/tests/drm_connector_test.c static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test) · line 84
Quoted 5 lines
drivers/gpu/drm/tests/drm_connector_test.c +1
-0static 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