[PATCH v8 3/4] drm: Suppress intentional warning backtraces in scaling unit tests

Albert Esteve aesteve at redhat.com
Wed May 6 01:37:39 PDT 2026


On Mon, May 4, 2026 at 12:04 PM Maxime Ripard <mripard at kernel.org> wrote:
>
> Hi,
>
> On Mon, May 04, 2026 at 09:41:27AM +0200, Albert Esteve wrote:
> > From: Guenter Roeck <linux at roeck-us.net>
> >
> > The drm_test_rect_calc_hscale and drm_test_rect_calc_vscale unit tests
> > intentionally trigger warning backtraces by providing bad parameters to
> > the tested functions. What is tested is the return value, not the existence
> > of a warning backtrace. Suppress the backtraces to avoid clogging the
> > kernel log and distraction from real problems.
> >
> > Tested-by: Linux Kernel Functional Testing <lkft at linaro.org>
> > Acked-by: Dan Carpenter <dan.carpenter at linaro.org>
> > Acked-by: Maíra Canal <mcanal at igalia.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> > Cc: David Airlie <airlied at gmail.com>
> > Cc: Daniel Vetter <daniel at ffwll.ch>
> > Signed-off-by: Guenter Roeck <linux at roeck-us.net>
> > Signed-off-by: Alessandro Carminati <acarmina at redhat.com>
> > Acked-by: David Gow <david at davidgow.net>
> > Signed-off-by: Albert Esteve <aesteve at redhat.com>
> > ---
> >  drivers/gpu/drm/tests/drm_rect_test.c | 23 +++++++++++++++++++----
> >  1 file changed, 19 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c
> > index 17e1f34b76101..818e16e80c8f9 100644
> > --- a/drivers/gpu/drm/tests/drm_rect_test.c
> > +++ b/drivers/gpu/drm/tests/drm_rect_test.c
> > @@ -409,8 +409,16 @@ static void drm_test_rect_calc_hscale(struct kunit *test)
> >       const struct drm_rect_scale_case *params = test->param_value;
> >       int scaling_factor;
> >
> > -     scaling_factor = drm_rect_calc_hscale(&params->src, &params->dst,
> > -                                           params->min_range, params->max_range);
> > +     /*
> > +      * drm_rect_calc_hscale() generates a warning backtrace whenever bad
> > +      * parameters are passed to it. This affects all unit tests with an
> > +      * error code in expected_scaling_factor.
> > +      */
> > +     kunit_warning_suppress(test) {
> > +             scaling_factor = drm_rect_calc_hscale(&params->src, &params->dst,
> > +                                                   params->min_range,
> > +                                                   params->max_range);
> > +     }
> >
> >       KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor);
> >  }
> > @@ -420,8 +428,15 @@ static void drm_test_rect_calc_vscale(struct kunit *test)
> >       const struct drm_rect_scale_case *params = test->param_value;
> >       int scaling_factor;
> >
> > -     scaling_factor = drm_rect_calc_vscale(&params->src, &params->dst,
> > -                                           params->min_range, params->max_range);
> > +     /*
> > +      * drm_rect_calc_vscale() generates a warning backtrace whenever bad
> > +      * parameters are passed to it. This affects all unit tests with an
> > +      * error code in expected_scaling_factor.
> > +      */
> > +     kunit_warning_suppress(test) {
> > +             scaling_factor = drm_rect_calc_vscale(&params->src, &params->dst,
> > +                                                   params->min_range, params->max_range);
> > +     }
> >
> >       KUNIT_EXPECT_EQ(test, scaling_factor, params->expected_scaling_factor);
> >  }
>
> For both I think we should add KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT calls, no?

Hi Maxime,

It may indeed add verification value by ensuring the call actually
generates the expected warning.

The original patch did not include count checks on the version I
inherited it from (i.e.,
https://lore.kernel.org/all/20250526132755.166150-5-acarmina@redhat.com/),
so I kept the same approach while adapting to the API changes. That
said, the check is simple to add, so I could include it in the next
version.

BR,
Albert

>
> Maxime




More information about the linux-riscv mailing list