Source-Based Code Coverage: Merge results from running mulitple binaries

I’m using LLVM’s source-based code coverage feature to prepare coverage reports for my code base.

However, the tests for the the (rather large, badly coupled…) code base are distributed across multiple binaries, which use somwhat of a homebrewn test framework. It is not easily possible to combine all tests in one binary.

I would like the coverage reports to reflect the coverage resulting from running all those test binaries. I know that I can merge the generated ‘instruction profiles’ from each run using llvm-profdata merge, but llvm-cov show still requires me to specify a single binary. Is there any way of generating coverage across multiple binaries?

llvm-cov show does actually allow you to specify multiple binaries, even if that doesn’t seem obvious at first. Basically the first name not part of a flag is taken as a binary, but you can add subsequent binaries by using -object <binary2> -object <binary3> ....

See the synopsis here llvm-cov - emit coverage information — LLVM 12 documentation

1 Like

Oh thanks! Somehow I missed that.