I’m trying to replicate a workflow I use from gcov with llvm. My workflow is this:
- Build my code with coverage instrumentation
- Run a test
- Get a binary coverage artifact for the test
- Filter the binary artifact to a certain set of files (the “files under test”
- Go to 2 for other tests in the test suite. Steps 2-4 might also be run multiple times in parallel.
- Now that all tests are run and filtered, merge all the binary coverage objects.
- 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:
- I am not aware of an existing tool for merging the json output from multiple invocations of “llvm-cov export”
- 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.