From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Arthur Grillo <arthurgrillo@riseup.net>
Cc: carlos.craveiro@usp.br, tales.aparecida@gmail.com,
dlatypov@google.com, javierm@redhat.com,
dri-devel@lists.freedesktop.org, mairacanal@riseup.net,
maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com,
matheus.vieira.g@usp.br
Subject: Re: [PATCH 2/5] drm/tests: Test drm_rect_calc_hscale()
Date: Wed, 22 Mar 2023 16:29:24 +0200 [thread overview]
Message-ID: <ZBsQxHJNFmuAbcUA@intel.com> (raw)
In-Reply-To: <20230322140701.69852-3-arthurgrillo@riseup.net>
On Wed, Mar 22, 2023 at 11:06:58AM -0300, Arthur Grillo wrote:
> Insert test for the drm_rect_hscale() function, besides the test
> for the usual case it also test for the exceptions.
>
> Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
> ---
> drivers/gpu/drm/tests/drm_rect_test.c | 58 +++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
>
> diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c
> index f700984f70a8..7e02393092fa 100644
> --- a/drivers/gpu/drm/tests/drm_rect_test.c
> +++ b/drivers/gpu/drm/tests/drm_rect_test.c
> @@ -9,6 +9,8 @@
>
> #include <drm/drm_rect.h>
>
> +#include <linux/errno.h>
> +
> static void drm_rect_compare(struct kunit *test, const struct drm_rect *r,
> const struct drm_rect *expected)
> {
> @@ -225,12 +227,68 @@ static void drm_test_rect_intersect(struct kunit *test)
> KUNIT_EXPECT_FALSE_MSG(test, visible, "Interserction should not be a visible rect");
> }
>
> +static void drm_test_rect_calc_hscale(struct kunit *test)
> +{
> + struct drm_rect src, dst;
> + int scaling_factor;
> +
> + drm_rect_init(&src, 0, 0, 2, 0);
I think we have a few places in the code that make the assumption
that src uses .16 binary fixed point. Not many, but few.
> + drm_rect_init(&dst, 0, 0, 1, 0);
> +
> + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX);
The negative min scale factor is nonsensical.
> +
> + KUNIT_EXPECT_EQ(test, scaling_factor, 2);
> +}
> +
> +static void drm_test_rect_calc_hscale_out_of_range(struct kunit *test)
> +{
> + struct drm_rect src, dst;
> + int scaling_factor;
> +
> + drm_rect_init(&src, 0, 0, 10, 0);
> + drm_rect_init(&dst, 0, 0, 1, 0);
> +
> + scaling_factor = drm_rect_calc_hscale(&src, &dst, 3, 5);
> +
> + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE);
> +
> + drm_rect_init(&src, 0, 0, 2, 0);
> + drm_rect_init(&dst, 0, 0, 1, 0);
> +
> + scaling_factor = drm_rect_calc_hscale(&src, &dst, 3, 5);
> +
> + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE);
> +}
> +
> +static void drm_test_rect_calc_hscale_negative_args(struct kunit *test)
> +{
> + struct drm_rect src, dst;
> + int scaling_factor;
> +
> + drm_rect_init(&src, 0, 0, -1, 0);
> + drm_rect_init(&dst, 0, 0, 1, 0);
> +
> + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX);
> +
> + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL);
> +
> + drm_rect_init(&src, 0, 0, 1, 0);
> + drm_rect_init(&dst, 0, 0, -1, 0);
> +
> + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX);
> +
> + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL);
> +}
> +
> static struct kunit_case drm_rect_tests[] = {
> KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero),
> KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped),
> KUNIT_CASE(drm_test_rect_clip_scaled_clipped),
> KUNIT_CASE(drm_test_rect_clip_scaled_signed_vs_unsigned),
> KUNIT_CASE(drm_test_rect_intersect),
> + KUNIT_CASE(drm_test_rect_calc_hscale),
> + KUNIT_CASE(drm_test_rect_calc_hscale_out_of_range),
> + KUNIT_CASE(drm_test_rect_calc_hscale_negative_args),
> { }
> };
>
> --
> 2.39.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2023-03-22 14:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 14:06 [PATCH 0/5] Create tests for the drm_rect functions Arthur Grillo
2023-03-22 14:06 ` [PATCH 1/5] drm/tests: Test drm_rect_intersect() Arthur Grillo
2023-03-22 14:26 ` Ville Syrjälä
2023-03-22 19:39 ` Arthur Grillo Queiroz Cabral
2023-03-22 14:06 ` [PATCH 2/5] drm/tests: Test drm_rect_calc_hscale() Arthur Grillo
2023-03-22 14:29 ` Ville Syrjälä [this message]
2023-03-22 14:06 ` [PATCH 3/5] drm/tests: Test drm_rect_calc_vscale() Arthur Grillo
2023-03-22 14:07 ` [PATCH 4/5] drm/tests: Test drm_rect_rotate() Arthur Grillo
2023-03-22 14:32 ` Ville Syrjälä
2023-03-22 14:07 ` [PATCH 5/5] drm/test: Test drm_rect_rotate_inv() Arthur Grillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZBsQxHJNFmuAbcUA@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=airled@gmail.com \
--cc=andrealmeid@riseup.net \
--cc=arthurgrillo@riseup.net \
--cc=carlos.craveiro@usp.br \
--cc=dlatypov@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=mairacanal@riseup.net \
--cc=matheus.vieira.g@usp.br \
--cc=maxime@cerno.tech \
--cc=tales.aparecida@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox