<div dir="ltr"><div>Will work on that.</div><div><br></div><div>Dipam Turkar<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 28, 2023 at 8:39 PM Maxime Ripard <<a href="mailto:mripard@kernel.org">mripard@kernel.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Sat, Nov 11, 2023 at 12:54:53AM +0530, Dipam Turkar wrote:<br>
> Introduce unit tests for the drm_mode_create_dvi_i_properties() function to ensure<br>
> the proper creation of DVI-I specific connector properties.<br>
> <br>
> Signed-off-by: Dipam Turkar <<a href="mailto:dipamt1729@gmail.com" target="_blank">dipamt1729@gmail.com</a>><br>
> ---<br>
>  drivers/gpu/drm/tests/drm_connector_test.c | 38 ++++++++++++++++++++++<br>
>  1 file changed, 38 insertions(+)<br>
> <br>
> diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c<br>
> index c66aa2dc8d9d..9ac1fd32c579 100644<br>
> --- a/drivers/gpu/drm/tests/drm_connector_test.c<br>
> +++ b/drivers/gpu/drm/tests/drm_connector_test.c<br>
> @@ -4,6 +4,9 @@<br>
>   */<br>
>  <br>
>  #include <drm/drm_connector.h><br>
> +#include <drm/drm_device.h><br>
> +#include <drm/drm_drv.h><br>
> +#include <drm/drm_kunit_helpers.h><br>
>  <br>
>  #include <kunit/test.h><br>
>  <br>
> @@ -58,6 +61,30 @@ static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test)<br>
>       KUNIT_EXPECT_LT(test, ret, 0);<br>
>  };<br>
>  <br>
> +/*<br>
> + * Test that drm_mode_create_dvi_i_properties() succeeds and<br>
> + * DVI-I subconnector and select subconectors properties have<br>
> + * been created.<br>
> + */<br>
> +static void drm_test_mode_create_dvi_i_properties(struct kunit *test)<br>
> +{<br>
> +     struct drm_device *drm;<br>
> +     struct device *dev;<br>
> +<br>
> +     dev = drm_kunit_helper_alloc_device(test);<br>
> +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);<br>
> +<br>
> +     drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);<br>
> +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);<br>
> +<br>
> +     KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);<br>
> +     KUNIT_EXPECT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_select_subconnector_property);<br>
> +     KUNIT_EXPECT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_subconnector_property);<br>
> +<br>
> +     // Expect the function to return 0 if called twice.<br>
<br>
This is not the proper comment format<br>
<br>
> +     KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);<br>
<br>
This should be in a separate test, with a separate description. We want<br>
to test two things: that the function works well, and that the function<br>
still works if we call it a second time.<br>
<br>
> +}<br>
> +<br>
>  static struct kunit_case drm_get_tv_mode_from_name_tests[] = {<br>
>       KUNIT_CASE_PARAM(drm_test_get_tv_mode_from_name_valid,<br>
>                        drm_get_tv_mode_from_name_valid_gen_params),<br>
> @@ -70,7 +97,18 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = {<br>
>       .test_cases = drm_get_tv_mode_from_name_tests,<br>
>  };<br>
<br>
The test should be next to the test suite definition<br>
<br>
> +static struct kunit_case drm_connector_tests[] = {<br>
> +     KUNIT_CASE(drm_test_mode_create_dvi_i_properties),<br>
> +     { }<br>
> +};<br>
> +<br>
> +static struct kunit_suite drm_connector_test_suite = {<br>
> +     .name = "drm_connector",<br>
<br>
That's too generic, the test suite is only about<br>
drm_mode_create_dvi_i_properties(), not drm_connector in general.<br>
<br>
> +     .test_cases = drm_connector_tests,<br>
> +};<br>
> +<br>
>  kunit_test_suite(drm_get_tv_mode_from_name_test_suite);<br>
> +kunit_test_suite(drm_connector_test_suite);<br>
<br>
kunit_test_suites<br>
<br>
Maxime<br>
</blockquote></div>