From 3405b5ad3dc6f1e2ca252ad9fbe1d3e5ef93e1c1 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Wed, 17 Sep 2025 11:22:01 +0100
Subject: [PATCH] drm/tests: Add cmd line test for reflect_[xy] not being last
 param

To ensure we don't get a regression on handling reflect_[xy]
in the middle of the command line string, add a test for it.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 .../gpu/drm/tests/drm_cmdline_parser_test.c   | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

--- a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c
+++ b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c
@@ -724,6 +724,29 @@ static void drm_test_cmdline_multiple_op
 	KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED);
 }
 
+static void drm_test_cmdline_multiple_options2(struct kunit *test)
+{
+	struct drm_cmdline_mode mode = { };
+	const char *cmdline = "720x480,reflect_x,rotate=270";
+
+	KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline,
+									  &no_connector, &mode));
+	KUNIT_EXPECT_TRUE(test, mode.specified);
+	KUNIT_EXPECT_EQ(test, mode.xres, 720);
+	KUNIT_EXPECT_EQ(test, mode.yres, 480);
+	KUNIT_EXPECT_EQ(test, mode.rotation_reflection, (DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X));
+
+	KUNIT_EXPECT_FALSE(test, mode.refresh_specified);
+
+	KUNIT_EXPECT_FALSE(test, mode.bpp_specified);
+
+	KUNIT_EXPECT_FALSE(test, mode.rb);
+	KUNIT_EXPECT_FALSE(test, mode.cvt);
+	KUNIT_EXPECT_FALSE(test, mode.interlace);
+	KUNIT_EXPECT_FALSE(test, mode.margins);
+	KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED);
+}
+
 static void drm_test_cmdline_bpp_extra_and_option(struct kunit *test)
 {
 	struct drm_cmdline_mode mode = { };
@@ -1057,6 +1080,7 @@ static struct kunit_case drm_cmdline_par
 	KUNIT_CASE(drm_test_cmdline_vmirror),
 	KUNIT_CASE(drm_test_cmdline_margin_options),
 	KUNIT_CASE(drm_test_cmdline_multiple_options),
+	KUNIT_CASE(drm_test_cmdline_multiple_options2),
 	KUNIT_CASE(drm_test_cmdline_bpp_extra_and_option),
 	KUNIT_CASE(drm_test_cmdline_extra_and_option),
 	KUNIT_CASE(drm_test_cmdline_freestanding_options),
