diff mbox series

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

Message ID 20190827115850.25731-4-mripard@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/modes: Add a switch to differentiate free standing options | expand

Commit Message

Maxime Ripard Aug. 27, 2019, 11:58 a.m. UTC
From: Maxime Ripard <maxime.ripard@bootlin.com>

Let's add some unit tests for the recent bugs we just fixed.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 .../gpu/drm/selftests/drm_cmdline_selftests.h |   7 +
 .../drm/selftests/test-drm_cmdline_parser.c   | 130 ++++++++++++++++++
 2 files changed, 137 insertions(+)

Comments

Thomas Graichen Aug. 27, 2019, 7:36 p.m. UTC | #1
hi maxime,

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

Tested-by: thomas graichen <thomas.graichen@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
>
Jernej Škrabec Aug. 29, 2019, 6:16 p.m. UTC | #2
Hi!

Dne torek, 27. avgust 2019 ob 13:58:50 CEST je Maxime Ripard napisal(a):
> From: Maxime Ripard <maxime.ripard@bootlin.com>
> 
> Let's add some unit tests for the recent bugs we just fixed.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  .../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

Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>

Best regards,
Jernej
diff mbox series

Patch

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 = { };