Re: [PATCH] lib/math/rational.c: Fix divide by zero
From: Daniel Latypov
Date: Mon May 24 2021 - 18:56:42 EST
On Mon, May 24, 2021 at 3:04 PM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
>
> On 5/24/21 9:55 AM, Daniel Latypov wrote:
> > diff --git a/lib/math/Kconfig b/lib/math/Kconfig
> > index f19bc9734fa7..20460b567493 100644
> > --- a/lib/math/Kconfig
> > +++ b/lib/math/Kconfig
> > @@ -15,3 +15,14 @@ config PRIME_NUMBERS
> >
> > config RATIONAL
> > bool
> > +
> > +config RATIONAL_KUNIT_TEST
> > + tristate "KUnit test for rational number support" if !KUNIT_ALL_TESTS
> > + # depends on KUNIT && RATIONAL # this is how it should work, but
> > + depends on KUNIT
> > + select RATIONAL # I don't grok kconfig enough to know why this
>
> Only to set the symbol CONFIG_RATIONAL.
> Then when 'make' descends into the lib/math/ subdir and looks at its Makefile,
> it will decide to build the binary rational.o.
>
> obj-$(CONFIG_RATIONAL) += rational.o
>
Ack, I understand that much.
My confusion is why this doesn't work:
$ ./tools/testing/kunit/kunit.py run --kunitconfig /dev/stdin <<EOF
CONFIG_KUNIT=y
CONFIG_RATIONAL=y
EOF
...
ERROR:root:Provided Kconfig is not contained in validated .config.
Following fields found in kunitconfig, but not in .config:
CONFIG_RATIONAL=y
What it's complaining about is that `make ARCH=um olddefconfig` is
leaving CONFIG_RATIONAL=y unset.
Stripping out kunit.py, it's this:
$ echo -e 'CONFIG_KUNIT=y\nCONFIG_RATIONAL=y' > .kunit/.config
$ make ARCH=um olddefconfig O=.kunit
$ grep RATIONAL .kunit/.config
I'm not versed in Kconfig enough to know why CONFIG_RATIONAL=y is
getting removed.
>
> > is necessary
> > + default KUNIT_ALL_TESTS
> > + help
> > + This builds unit tests for the rational number support.
> > +
> > + If unsure, say N.
>
>
> --
> ~Randy
>