Search code examples
code-coveragegnu-makelcov

Makefile: generic way to indccate all available .info file from one folder to lcov


I'm working on some tests and I'm using lcov In order to correctly manage the coverage of all tests, my makefile:

  1. compile each test
  2. launch the test
  3. generate the .info file using geninfo
  4. delete *.gcda, *.gcno

When this is made for all tests, I want to generate the whole coverage by calling: lccov --add-tracefile <name>.info -o global_coverage.info

However, it seems that I need to indicate all .info file by --add-tracefile <name>.info

Ex: if I've file1.info and file2.info, I need to call: lccov --add-tracefile file1.info --add-tracefile file2.info -o global_coverage.info

I can retrieve the list of all .info file by

# Get all .info file for coverag
INFO_FILES = $(wildcard $(TEST_BUILD_DIR)/*.info)

Is there a generic way to call this lcov tool by indicating all .info file ?

Thanks


Solution

  • You can use this:

    # Get all .info file for coverag
    INFO_FILES := $(wildcard $(TEST_BUILD_DIR)/*.info)
    
    global_coverage.info: $(INFO_FILES)
            lccov $(addprefix --add-tracefile ,$^) -o $@