[llvm-dev] Filter and merge coverage reports

Chris Brown via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 29 22:45:15 PDT 2019

I’m trying to replicate a workflow I use from gcov with llvm. My workflow
is this:
1) Build my code with coverage instrumentation
2) Run a test
3) Get a binary coverage artifact for the test
4) Filter the binary artifact to a certain set of files (the “files under
5) Go to 2 for other tests in the test suite. Steps 2-4 might also be run
multiple times in parallel.
6) Now that all tests are run and filtered, merge all the binary coverage
7) Make an html report from the merged object

Note that a merge of filtered coverage artifacts is not the same as a
filter of merged coverage artifacts. For example, I run two tests: one is a
unit test of a math library, and the other is a unit test of some
application that uses the math library. What I want to do is filter the
math unit test coverage output to show only the math library files, and
filter the application test coverage output to show only the application’s
files. Then I want to join them all into one report. The filtering must
happen before the merge.

With llvm-cov, I can create filtered reports from binary artifacts
(*.profdata files), and with llvm-profdata I can merge binary artifacts.
However, I’m not aware of a method of merging some intermediate coverage
data that has been filtered.

I thought that perhaps the json output from “llvm-cov export” would help
here; I could use “llvm-cov export -instr-profile=coverage1.profdata
MathTest math.c” to create a json of the filtered math test. However, this
doesn’t seem like a solution for at least two reasons:
1) I am not aware of an existing tool for merging the json output from
multiple invocations of “llvm-cov export”
2) I am not aware of a tool that produces html reports from the json
format, even if I could merge them.

Is my workflow possible? It’s easy with gcov, but I don’t know if it
supported by llvm coverage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190429/c826bbc5/attachment.html>

More information about the llvm-dev mailing list