dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: tzimmermann@suse.de, "David Airlie" <airlied@linux.ie>,
	"Daniel Latypov" <dlatypov@google.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	"José Expósito" <jose.exposito89@gmail.com>,
	"KUnit Development" <kunit-dev@googlegroups.com>
Subject: Re: [RFC PATCH 1/1] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()
Date: Thu, 2 Jun 2022 10:07:56 -0700	[thread overview]
Message-ID: <CABVgOSkCxu2xBnxwc6mO2AQaqzTbDf53PJzT2QvZNyLeumt5hg@mail.gmail.com> (raw)
In-Reply-To: <e26de140-afb7-7b1b-4826-6ac4f3a4fe02@redhat.com>

On Thu, Jun 2, 2022 at 9:27 AM Javier Martinez Canillas
<javierm@redhat.com> wrote:
>
> Hello José,
>
> On 5/30/22 12:20, José Expósito wrote:
> > Test the conversion from XRGB8888 to RGB332.
> >
> > What is tested?
> >
> >  - Different values for the X in XRGB8888 to make sure it is ignored
> >  - Different clip values: Single pixel and full and partial buffer
> >  - Well know colors: White, black, red, green, blue, magenta, yellow
> >    and cyan
> >  - Other colors: Randomly picked
> >  - Destination pitch
> >
> > Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
> > Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> > ---
>
> Thanks a lot for working on this! It's very cool to see the first KUnit
> tests added to DRM :)
>
> >  drivers/gpu/drm/Kconfig                  |  12 ++
> >  drivers/gpu/drm/Makefile                 |   3 +
> >  drivers/gpu/drm/drm_format_helper_test.c | 166 +++++++++++++++++++++++
> >  3 files changed, 181 insertions(+)
> >  create mode 100644 drivers/gpu/drm/drm_format_helper_test.c
> >
> > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> > index e88c497fa010..d92be6faef15 100644
> > --- a/drivers/gpu/drm/Kconfig
> > +++ b/drivers/gpu/drm/Kconfig
> > @@ -76,6 +76,18 @@ config DRM_KMS_HELPER
> >       help
> >         CRTC helpers for KMS drivers.
> >
> > +config DRM_FORMAR_HELPER_TEST
>
> I wonder if we want this level of detail for the test Kconfig symbols.
> Maybe we could just have a DRM_KUNIT_TEST symbol that will enable all
> the KUnit test suites for DRM ?
>
> > +     bool "drm_format_helper tests" if !KUNIT_ALL_TESTS
> > +     depends on DRM && KUNIT=y
> > +     select DRM_KMS_HELPER
>
> Daniel didn't like this `select DRM_KMS_HELPER` and I think that we can avoid
> it if instead drm_format_helper_test.c is included in drm_format_helper.c, i.e:
>
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index a3ccd8bc966f..d63e02da528f 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -692,3 +692,7 @@ void drm_fb_xrgb8888_to_mono(void *dst, unsigned int dst_pitch, const void *vadd
>         kfree(src32);
>  }
>  EXPORT_SYMBOL(drm_fb_xrgb8888_to_mono);
> +
> +#ifdef DRM_KUNIT_TEST
> +#include "drm_format_helper_test.c"
> +#endif
>
> This also has the advantage that will allow to have KUnit tests for the static
> functions that are only available in the drm_format_helper.c compilation unit.
>
> >  obj-$(CONFIG_DRM_DEBUG_SELFTEST) += selftests/
> > +obj-$(CONFIG_DRM_FORMAR_HELPER_TEST) += drm_kms_helper.o \
> > +             drm_format_helper_test.o
>
> And doing that will also allow you to get rid of this, since just selecting
> CONFIG_DRM_KUNIT_TEST=y would be enough for the tests built and run by KUnit.
>

This is definitely something other KUnit tests (apparmor, elf, etc)
are doing, and it's generally fine. You do lose the ability to build
the tests as a separate module, though. (This is not usually a big
problem, but there are some cases where it's useful.)

That being said, I don't think 'select' is enough of a problem that
you should feel the need to refactor in this way just to avoid it.
Given most of the other DRM drivers (as well as DRM_DEBUG_SELFTEST)
are select-ing DRM_KMS_HELPER, it seems like a sensible enough thing
to continue doing for the KUnit test. As Daniel pointed out, as a
hidden option it was clearly always meant to be select-ed anyway.

Cheers,
-- David

  parent reply	other threads:[~2022-06-02 17:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30 10:20 [RFC PATCH 0/1] KUnit tests for drm_format_helper José Expósito
2022-05-30 10:20 ` [RFC PATCH 1/1] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332() José Expósito
2022-05-30 13:11   ` Maxime Ripard
2022-05-30 16:29     ` José Expósito
2022-05-30 22:57       ` Daniel Latypov
2022-05-31 18:44         ` José Expósito
2022-05-31 20:42           ` Daniel Latypov
2022-06-02 17:12       ` David Gow
2022-06-02 17:29         ` Javier Martinez Canillas
2022-06-02 17:45           ` Daniel Latypov
2022-06-02 16:26   ` Javier Martinez Canillas
2022-06-02 16:53     ` Daniel Latypov
2022-06-02 17:07     ` David Gow [this message]
2022-06-02 17:21       ` Javier Martinez Canillas
2022-06-06  9:43         ` José Expósito

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=CABVgOSkCxu2xBnxwc6mO2AQaqzTbDf53PJzT2QvZNyLeumt5hg@mail.gmail.com \
    --to=davidgow@google.com \
    --cc=airlied@linux.ie \
    --cc=dlatypov@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=jose.exposito89@gmail.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).