Re: [PATCH v2 2/2] lib/math/rational: Add Kunit test cases

From: Trent Piepho
Date: Tue May 25 2021 - 17:09:41 EST


On Tue, May 25, 2021 at 10:34 AM Daniel Latypov <dlatypov@xxxxxxxxxx> wrote:
> On Tue, May 25, 2021 at 7:43 AM Trent Piepho <tpiepho@xxxxxxxxx> wrote:
> > Adds a number of test cases that cover a range of possible code paths.
> >
> > Signed-off-by: Trent Piepho <tpiepho@xxxxxxxxx>
>
> Reviewed-by: Daniel Latypov <dlatypov@xxxxxxxxxx>
>
> Looks really good to me, just two nits.
>
> Tangent:
> I didn't check to see that this covers all the interesting cases, but
> it seems like it does.
> If you want, you can try generating a code coverage report to double check.
> Instructions for doing so can be found in
> https://lore.kernel.org/linux-kselftest/20210414222256.1280532-1-dlatypov@xxxxxxxxxx/
> I would have done that and included the #s in this email, but my
> workplace decided to subtly break my workstation in some way and I
> haven't gotten around to root causing...

I installed a gcc 6.4 toolchain and changed the uml_abort() call to
exit(), coverage was generated, but still truncated and incorrectly
near 0%. So what I did was crash after running all the test cases I
cared about by dividing by zero and then coverage data was produced
correctly. It's 100% by lines. But I think both possibilities when
the largest semiconvergent is exactly half the previous convergent
aren't tested.

> > lib/math/rational-test.c | 56 ++++++++++++++++++++++++++++++++++++++++
>
> Ah, sorry, I forgot to mention this in the previous email.
> If you look at kunit/style.rst docs, you'll see the documentation now
> states a preference for the name of this file to be one of
> {rational_test.c, rational_kunit.c}

Before I chose a name, I checked every file with kunit tests cases,
and *-test was the most common naming pattern, including the sample
case. I would be nice if changing the docs to say something is a
standard also updated the code to make that reality.