[PATCH 4/4] drm/selftests: modes: Add more unit tests for the cmdline parser

Thomas Graichen thomas.graichen at googlemail.com
Tue Aug 27 19:36:04 UTC 2019


hi maxime,

On Tue, Aug 27, 2019 at 1:59 PM Maxime Ripard <mripard at kernel.org> wrote:
>
> From: Maxime Ripard <maxime.ripard at bootlin.com>
>
> Let's add some unit tests for the recent bugs we just fixed.
>
> Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>

Tested-by: thomas graichen <thomas.graichen at gmail.com>

BEFORE (only "[PATCH v5 05/12] drm/modes: Rewrite the command line
parser " applied):
my eachlink h6 mini tv box (which requires the video=HDMI-A-1:e
cmdline option to give any output on hdmi) did not show any hdmi
output any more (in 5.2 it still worked)

AFTER (the above patch plus this patch set here applied):
my eachlink h6 mini tv box gives output on hdmi again. i also did
check it the other way around: if i remove the video=HDMI-A-1:e option
i no longer get any hdmi output as expected. as a result this patch
series fixes the problem/regression for me.

best wishes - thomas

> ---
>  .../gpu/drm/selftests/drm_cmdline_selftests.h |   7 +
>  .../drm/selftests/test-drm_cmdline_parser.c   | 130 ++++++++++++++++++
>  2 files changed, 137 insertions(+)
>
> diff --git a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
> index b45824ec7c8f..6d61a0eb5d64 100644
> --- a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
> +++ b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
> @@ -9,6 +9,13 @@
>
>  #define cmdline_test(test)     selftest(test, test)
>
> +cmdline_test(drm_cmdline_test_force_d_only)
> +cmdline_test(drm_cmdline_test_force_D_only_dvi)
> +cmdline_test(drm_cmdline_test_force_D_only_hdmi)
> +cmdline_test(drm_cmdline_test_force_D_only_not_digital)
> +cmdline_test(drm_cmdline_test_force_e_only)
> +cmdline_test(drm_cmdline_test_margin_only)
> +cmdline_test(drm_cmdline_test_interlace_only)
>  cmdline_test(drm_cmdline_test_res)
>  cmdline_test(drm_cmdline_test_res_missing_x)
>  cmdline_test(drm_cmdline_test_res_missing_y)
> diff --git a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
> index 14c96edb13df..013de9d27c35 100644
> --- a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
> +++ b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
> @@ -17,6 +17,136 @@
>
>  static const struct drm_connector no_connector = {};
>
> +static int drm_cmdline_test_force_e_only(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(!drm_mode_parse_command_line_for_connector("e",
> +                                                          &no_connector,
> +                                                          &mode));
> +       FAIL_ON(mode.specified);
> +       FAIL_ON(mode.refresh_specified);
> +       FAIL_ON(mode.bpp_specified);
> +
> +       FAIL_ON(mode.rb);
> +       FAIL_ON(mode.cvt);
> +       FAIL_ON(mode.interlace);
> +       FAIL_ON(mode.margins);
> +       FAIL_ON(mode.force != DRM_FORCE_ON);
> +
> +       return 0;
> +}
> +
> +static int drm_cmdline_test_force_D_only_not_digital(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(!drm_mode_parse_command_line_for_connector("D",
> +                                                          &no_connector,
> +                                                          &mode));
> +       FAIL_ON(mode.specified);
> +       FAIL_ON(mode.refresh_specified);
> +       FAIL_ON(mode.bpp_specified);
> +
> +       FAIL_ON(mode.rb);
> +       FAIL_ON(mode.cvt);
> +       FAIL_ON(mode.interlace);
> +       FAIL_ON(mode.margins);
> +       FAIL_ON(mode.force != DRM_FORCE_ON);
> +
> +       return 0;
> +}
> +
> +static const struct drm_connector connector_hdmi = {
> +       .connector_type = DRM_MODE_CONNECTOR_HDMIB,
> +};
> +
> +static int drm_cmdline_test_force_D_only_hdmi(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(!drm_mode_parse_command_line_for_connector("D",
> +                                                          &connector_hdmi,
> +                                                          &mode));
> +       FAIL_ON(mode.specified);
> +       FAIL_ON(mode.refresh_specified);
> +       FAIL_ON(mode.bpp_specified);
> +
> +       FAIL_ON(mode.rb);
> +       FAIL_ON(mode.cvt);
> +       FAIL_ON(mode.interlace);
> +       FAIL_ON(mode.margins);
> +       FAIL_ON(mode.force != DRM_FORCE_ON_DIGITAL);
> +
> +       return 0;
> +}
> +
> +static const struct drm_connector connector_dvi = {
> +       .connector_type = DRM_MODE_CONNECTOR_DVII,
> +};
> +
> +static int drm_cmdline_test_force_D_only_dvi(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(!drm_mode_parse_command_line_for_connector("D",
> +                                                          &connector_dvi,
> +                                                          &mode));
> +       FAIL_ON(mode.specified);
> +       FAIL_ON(mode.refresh_specified);
> +       FAIL_ON(mode.bpp_specified);
> +
> +       FAIL_ON(mode.rb);
> +       FAIL_ON(mode.cvt);
> +       FAIL_ON(mode.interlace);
> +       FAIL_ON(mode.margins);
> +       FAIL_ON(mode.force != DRM_FORCE_ON_DIGITAL);
> +
> +       return 0;
> +}
> +
> +static int drm_cmdline_test_force_d_only(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(!drm_mode_parse_command_line_for_connector("d",
> +                                                          &no_connector,
> +                                                          &mode));
> +       FAIL_ON(mode.specified);
> +       FAIL_ON(mode.refresh_specified);
> +       FAIL_ON(mode.bpp_specified);
> +
> +       FAIL_ON(mode.rb);
> +       FAIL_ON(mode.cvt);
> +       FAIL_ON(mode.interlace);
> +       FAIL_ON(mode.margins);
> +       FAIL_ON(mode.force != DRM_FORCE_OFF);
> +
> +       return 0;
> +}
> +
> +static int drm_cmdline_test_margin_only(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(drm_mode_parse_command_line_for_connector("m",
> +                                                         &no_connector,
> +                                                         &mode));
> +
> +       return 0;
> +}
> +
> +static int drm_cmdline_test_interlace_only(void *ignored)
> +{
> +       struct drm_cmdline_mode mode = { };
> +
> +       FAIL_ON(drm_mode_parse_command_line_for_connector("i",
> +                                                         &no_connector,
> +                                                         &mode));
> +
> +       return 0;
> +}
> +
>  static int drm_cmdline_test_res(void *ignored)
>  {
>         struct drm_cmdline_mode mode = { };
> --
> 2.21.0
>


More information about the dri-devel mailing list