Re: [PATCH v3 3/3] gpio: add kunit test cases for the GPIO subsystem

From: Bartosz Golaszewski

Date: Tue May 26 2026 - 05:26:30 EST


On Tue, May 26, 2026 at 11:07 AM David Gow <david@xxxxxxxxxxxx> wrote:
>
> Le 22/05/2026 à 9:42 PM, Bartosz Golaszewski a écrit :
> > Add a module containing kunit test cases for GPIO core. The idea is to
> > use it to test functionalities that can't easily be tested from
> > user-space with kernel selftests or GPIO character device test suites
> > provided by the libgpiod package.
> >
> > For now add test cases that verify software node based lookup and ensure
> > that a GPIO provider unbinding with active consumers does not cause a
> > crash.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > ---
>
> This is a nice looking test, thanks.
>
> Reviewed-by: David Gow <david@xxxxxxxxxxxx>
>
> Happy for this (and the previous two patches) to go in via gpio, but if
> you'd rather them go in via the KUnit tree, let me know.
>

I'll take it through the GPIO tree, thanks.

> Cheers,
> -- David
>
> > drivers/gpio/Kconfig | 8 +
> > drivers/gpio/Makefile | 1 +
> > drivers/gpio/gpiolib-kunit.c | 358 +++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 367 insertions(+)
> >
> > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> > index 00fcab5d09a4294ed778cea78af5867a0f6e481b..0306005fb7d65ae85905e967b9065fd74db753db 100644
> > --- a/drivers/gpio/Kconfig
> > +++ b/drivers/gpio/Kconfig
> > @@ -102,6 +102,14 @@ config GPIO_CDEV_V1
> > This ABI version is deprecated.
> > Please use the latest ABI for new developments.
> >
> > +config GPIO_KUNIT
> > + tristate "Build GPIO Kunit test cases"
> > + depends on KUNIT
> > + default KUNIT_ALL_TESTS
> > + help
> > + Say Y here to build the module containing Kunit test cases verifying
> > + the functionality of the GPIO subsystem.
> > +
>
>
> FYI: If you want to add CONFIG_GPIOLIB=y to
> tools/testing/kunit/configs/all_tests.config, we can enable these tests
> when the --alltests flag is passed to kunit.py.
>

Sure, I'll send a separate patch for this.

Bart