Insert parameterized test for the drm_rect_calc_vscale() to ensure
correctness and prevent future regressions. Besides the test for the
usual case, tests the exceptions.
It uses the same struct from drm_rect_calc_hscale().
Signed-off-by: Arthur Grillo <arthurgrillo@xxxxxxxxxx>
---
drivers/gpu/drm/tests/drm_rect_test.c | 59 +++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c
index 44150545c1bc..a1fd9b2c5128 100644
--- a/drivers/gpu/drm/tests/drm_rect_test.c
+++ b/drivers/gpu/drm/tests/drm_rect_test.c
@@ -414,6 +414,64 @@ static void drm_test_rect_calc_hscale(struct kunit *test)
KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor);
}
+static const struct drm_rect_scale_case drm_rect_vscale_cases[] = {
+ {
+ .name = "normal use",
+ .src = DRM_RECT_INIT(0, 0, 0, 2 << 16),
+ .dst = DRM_RECT_INIT(0, 0, 0, 1 << 16),
+ .min_range = 0, .max_range = INT_MAX,
+ .expected_scaling_factor = 2,
+ },
+ {
+ .name = "out of max range",
+ .src = DRM_RECT_INIT(0, 0, 0, 10 << 16),
+ .dst = DRM_RECT_INIT(0, 0, 0, 1 << 16),
+ .min_range = 3, .max_range = 5,
+ .expected_scaling_factor = -ERANGE,
+ },
+ {
+ .name = "out of min range",
+ .src = DRM_RECT_INIT(0, 0, 0, 2 << 16),
+ .dst = DRM_RECT_INIT(0, 0, 0, 1 << 16),
+ .min_range = 3, .max_range = 5,
+ .expected_scaling_factor = -ERANGE,
+ },
+ {
+ .name = "zero dst height",
+ .src = DRM_RECT_INIT(0, 0, 0, 2 << 16),
+ .dst = DRM_RECT_INIT(0, 0, 0, 0 << 16),
+ .min_range = 0, .max_range = INT_MAX,
+ .expected_scaling_factor = 0,
+ },
+ {
+ .name = "negative src height",
+ .src = DRM_RECT_INIT(0, 0, 0, -(1 << 16)),
+ .dst = DRM_RECT_INIT(0, 0, 0, 1 << 16),
+ .min_range = 0, .max_range = INT_MAX,
+ .expected_scaling_factor = -EINVAL,
+ },
+ {
+ .name = "negative dst height",
+ .src = DRM_RECT_INIT(0, 0, 0, 1 << 16),
+ .dst = DRM_RECT_INIT(0, 0, 0, -(1 << 16)),
+ .min_range = 0, .max_range = INT_MAX,
+ .expected_scaling_factor = -EINVAL,
+ },
+};
+