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

From: Daniel Latypov
Date: Tue May 25 2021 - 18:03:40 EST

On Tue, May 25, 2021 at 2:09 PM Trent Piepho <tpiepho@xxxxxxxxx> wrote:
> 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
> >
> > 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.

Yeah, it's finicky.
Hopefully Brendan's change to cleanly shutdown the kernel at the end
of the tests might make it a bit more robust (still probably requires

Thanks for running it!
It's nice to know we have 100% (line) coverage.

> > > 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.

Yeah, it's frustrating...
Andy sent out some changes renaming a lot of the files, but we've not
managed to get everything up to date.