3.1.22. waf_tools.gcov

Integration of Gcov and gcovr into the Waf build system.

This waf tool adds code-coverage support to unit test builds. When the --coverage command-line flag is passed, the tool injects GCC’s --coverage compiler and linker flags into tasks that carry the test feature and schedules a post-build step that invokes gcovr to produce a coverage report.

3.1.22.1. Usage

  1. Load the tool during options and configure:

    def options(opt):
        opt.load("gcov", tooldir=TOOLDIR)
    
    def configure(ctx):
        ctx.load("gcov", tooldir=TOOLDIR)
    
  2. Run the build with coverage enabled:

    waf build_(app|bootloader)_unit_test_gcc --coverage
    

3.1.22.2. Dependencies

Functions

configure(ctx)

Configure the build environment for coverage.

coverage(bld)

Executes gcovr with the configuration file stored in bld.gcovr_cfg.

gcov(self)

Register a post-build coverage step for test targets, if coverage is enabled.

options(opt)

Register the --coverage command-line option.

test_stdout_stderr(bld)

Pretty-prints stdout/stderr of unit test results to the console.