Re: [PATCH v15 06/10] iio: test: add basic tests for the iio-rescale driver

From: Liam Beguin
Date: Tue Jun 28 2022 - 13:06:37 EST


Hi Geert,

On Mon, Jun 27, 2022 at 09:22:29AM +0200, Geert Uytterhoeven wrote:
> Hi Liam,
>
> On Mon, Feb 14, 2022 at 12:00 AM Liam Beguin <liambeguin@xxxxxxxxx> wrote:
> > The iio-rescale driver supports various combinations of scale types and
> > offsets. These can often result in large integer multiplications. Make
> > sure these calculations are done right by adding a set of kunit test
> > cases that build on top of iio-test-format.
> >
> > To run these tests, add the following to .kunitconfig
> > $ cat .kunitconfig
> > CONFIG_IIO=y
> > CONFIG_IIO_RESCALE_KUNIT_TEST=y
> > CONFIG_KUNIT=y
> >
> > Then run:
> > $ ./tools/testing/kunit/kunit.py run --kunitconfig .kunitconfig
> >
> > Signed-off-by: Liam Beguin <liambeguin@xxxxxxxxx>
> > Reviewed-by: Peter Rosin <peda@xxxxxxxxxx>
>
> Thanks for your patch, which is now commit 8e74a48d17d509bf
> ("iio: test: add basic tests for the iio-rescale driver") in v5.18.

Thanks! I also recently sent a fix for this which recently made it
upstream:
7a2f6f61e8ee ("iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=m")

> > --- a/drivers/iio/test/Kconfig
> > +++ b/drivers/iio/test/Kconfig
> > @@ -4,6 +4,16 @@
> > #
> >
> > # Keep in alphabetical order
> > +config IIO_RESCALE_KUNIT_TEST
> > + bool "Test IIO rescale conversion functions"
>
> Is there any reason this cannot be tristate, so I can always enable
> this as a module, and run the test by loading the module whenever
> I want?

I based this patch off of IIO_TEST_FORMAT, and also thought that Kunit
tests had to be built-in to work with tools/testing/kunit/kunit.py

Looking at the Documentation again, it seems I was (partially?) wrong,
kunit tests can be run as module, but manually.

I could give this a try and send a patch in the next few days.

Cheers,
Liam

> > + depends on KUNIT && !IIO_RESCALE
> > + default KUNIT_ALL_TESTS
> > + help
> > + If you want to run tests on the iio-rescale code say Y here.
> > +
> > + This takes advantage of ARCH=um to run tests and should be used by
> > + developers to tests their changes to the rescaling logic.
> > +
> > config IIO_TEST_FORMAT
> > bool "Test IIO formatting functions"
> > depends on KUNIT=y
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds