[PATCH v6 02/12] clk: Introduce Kunit Tests for the framework

Daniel Latypov dlatypov at google.com
Fri Mar 25 22:44:46 UTC 2022


On Fri, Mar 25, 2022 at 4:19 PM Stephen Boyd <sboyd at kernel.org> wrote:
>

<snip>

> > >
> > > This is cool. Thanks! Is it possible to add some 'coverage' command to
> > > kunit so we don't have to recall this invocation?
> >
> > This is documented at
> > https://www.kernel.org/doc/html/latest/dev-tools/kunit/running_tips.html#generating-code-coverage-reports-under-uml
> > It also includes pointers on how to use lcov to process the .gcda files.
> > I wrote it before --kconfig_add existed, so it just looks a bit different.
> >
> > The main blockers to directly supporting this in kunit.py are
> > 1.) this only works on UML
> > 2.) it needs gcc-6 or lower (and the kernel's min version is 5.1, iirc)...
> > 3.) in kernels older than 5.14, this requires some more hacks to get
> > working. So for the large portion of us stuck dealing with somewhat
> > older kernels, we'd have to do stuff manually anyway.
> >
> > For #1, we'd need different kconfig options and kunit.py's QEMU would
> > need some sort of userspace (busybox should be sufficient).
> > For #2, I don't recall what the precise issues were anymore. But I
> > think there were some more issues in gcc 8 or 9... :(
> >
> > >
> > > >
> > > > 3) intersected that with the total diff
> > >
> > > This would also be cool to do automatically with a revision range.
> >
> > Hmm, can you elaborate?
> > I assume you mean other revision ranges beyond this patch set?
>
> I mean somehow to tell kunit.py that I want incremental coverage
> information for a git revision range so that I can say something like
>
>         kunit.py incremental HEAD~3..HEAD
>
> and have it tell me the line coverage.

Yes, this is doable.

The steps I did were
1. generate coverage.info file per steps above
2. git diff HEAD~ > /tmp/inc.diff
3. <my personal script> --info=coverage.info --diff=/tmp/inc.diff

We'd just change step #2 to be `git diff HEAD~3..HEAD > /tmp/inc.diff`

As mentioned upthread, unfortunately my personal script in step #3
isn't open source or open sourceable atm.
I wrote it using some internal company code for parsing LCOV .info
files out of expediency, but there's nothing too complicated about it.
Just need to find what lines were "added" and intersect that w/ the
coverage data.


More information about the dri-devel mailing list