[PATCH] Tercera entrega completa

edagarmarjara posted 1 patch 2 years, 7 months ago
drivers/gpu/drm/tests/drm_rect_test.c | 30 +++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
[PATCH] Tercera entrega completa
Posted by edagarmarjara 2 years, 7 months ago
---
 drivers/gpu/drm/tests/drm_rect_test.c | 30 +++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c
index e9809ea32696..d03e1d9b208d 100644
--- a/drivers/gpu/drm/tests/drm_rect_test.c
+++ b/drivers/gpu/drm/tests/drm_rect_test.c
@@ -35,6 +35,7 @@ static void drm_test_rect_clip_scaled_div_by_zero(struct kunit *test)
 	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");
 }
 
+
 static void drm_test_rect_clip_scaled_not_clipped(struct kunit *test)
 {
 	struct drm_rect src, dst, clip;
@@ -196,11 +197,40 @@ static void drm_test_rect_clip_scaled_signed_vs_unsigned(struct kunit *test)
 	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");
 }
 
+static void drm_test_rect_clip_over_scaled_signed_vs_unsigned(struct kunit *test)
+{
+	
+	const void* gem_params(const void *prev, char *desc); 
+	struct drm_rect src, dst, clip;
+	bool visible;
+
+	/*
+	 * 'clip.x2 - dst.x1 >= dst width' could result a negative
+	 * src rectangle width which is no longer expected by the
+	 * code as it's using unsigned types. This could lead to
+	 * the clipped source rectangle appering visible when it
+	 * should have been fully clipped. Make sure both rectangles
+	 * end up invisible.
+	 * en esta parte cambio los valores y hago por aun mas afuera para el clip scaled
+	 * para poder saber si al exagerar mas aun la escala sigue funcionando
+	 */
+	drm_rect_init(&src, 2, 2, INT_MAX, INT_MAX);
+	drm_rect_init(&dst, 2, 2, 4, 4);
+	drm_rect_init(&clip, 6, 6, 3, 3);
+
+	visible = drm_rect_clip_scaled(&src, &dst, &clip);
+	
+	KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination should not be visible\n");
+	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");
+}
+
+
 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_clip_over_scaled_signed_vs_unsigned), //Test entrega 2
 	{ }
 };
 
-- 
2.34.1
Re: [PATCH] Tercera entrega completa
Posted by Maira Canal 2 years, 7 months ago
Hi edagarmarjara,

First, you need to include a commit message to the patch. Check [1] to 
see a basic guide to submit patches.

On 6/19/23 20:22, edagarmarjara wrote:
> ---
>   drivers/gpu/drm/tests/drm_rect_test.c | 30 +++++++++++++++++++++++++++
>   1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c
> index e9809ea32696..d03e1d9b208d 100644
> --- a/drivers/gpu/drm/tests/drm_rect_test.c
> +++ b/drivers/gpu/drm/tests/drm_rect_test.c
> @@ -35,6 +35,7 @@ static void drm_test_rect_clip_scaled_div_by_zero(struct kunit *test)
>   	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");
>   }
>   
> +

This line is not needed. You can run checkpatch.sh to catch common style 
mistakes.

>   static void drm_test_rect_clip_scaled_not_clipped(struct kunit *test)
>   {
>   	struct drm_rect src, dst, clip;
> @@ -196,11 +197,40 @@ static void drm_test_rect_clip_scaled_signed_vs_unsigned(struct kunit *test)
>   	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");
>   }
>   
> +static void drm_test_rect_clip_over_scaled_signed_vs_unsigned(struct kunit *test)
> +{
> +	
> +	const void* gem_params(const void *prev, char *desc);

Hum... I guess you don't need this function signature here.

> +	struct drm_rect src, dst, clip;
> +	bool visible;
> +
> +	/*
> +	 * 'clip.x2 - dst.x1 >= dst width' could result a negative
> +	 * src rectangle width which is no longer expected by the
> +	 * code as it's using unsigned types. This could lead to
> +	 * the clipped source rectangle appering visible when it
> +	 * should have been fully clipped. Make sure both rectangles
> +	 * end up invisible.
> +	 * en esta parte cambio los valores y hago por aun mas afuera para el clip scaled
> +	 * para poder saber si al exagerar mas aun la escala sigue funcionando

I believe you can try to explain the test in smaller comments. Sometimes 
the tests explain by itself. Also, avoid to use Spanish in comments.

> +	 */
> +	drm_rect_init(&src, 2, 2, INT_MAX, INT_MAX);
> +	drm_rect_init(&dst, 2, 2, 4, 4);
> +	drm_rect_init(&clip, 6, 6, 3, 3);
> +
> +	visible = drm_rect_clip_scaled(&src, &dst, &clip);
> +	
> +	KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination should not be visible\n");
> +	KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n");

I believe you could introduce more test cases for this test instead of 
only one.

> +}
> +
> +
>   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_clip_over_scaled_signed_vs_unsigned), //Test entrega 2

I believe you could remove the comment here.

[1] https://docs.kernel.org/process/submitting-patches.html

Best Regards,
- Maíra

>   	{ }
>   };
>