How can I display diagnostic data for the coverage workspace, including error and warning information?

The coverage workspace keeps instrumented code and corresponding static coverage data, together with some log and configuration files generated when the code was instrumented. You can display diagnostic data collected from the coverage workspace, including error and warning information, the number of files, etc. by using the -status option. Alternatively, you can use -status-verbose to display more detailed information.

By default, the coverage workspace located in the current directory will be scanned for diagnostic data. You can configure a different workspace location with the -workspace option.

Examples

cpptestcc -status
cpptestcc -status -workspace /path/to/workspace

cpptestcc -status-verbose
cpptestcc -status-verbose -workspace /path/to/workspace

How can I send diagnostic data for the coverage workspace to Parasoft Support?

You can create a technical support package for the coverage workspace by using the -techsupport option. This will create a .zip file that contains all the diagnostic data, including log files and preprocessed source code for files that could not be successfully instrumented.

By default, the coverage workspace located in the current directory will be scanned for diagnostic data. You can configure a different workspace location with the -workspace option.

Examples

cpptestcc -techsupport
cpptestcc -techsupport -workspace /path/to/workspace

What if one or more source files were not found when generating a report for application coverage?

When generating a coverage report, C/C++test requires all files that were instrumented for code coverage to be available in their original locations. If C/C++test cannot find a file in its original location, the coverage report is incomplete. In such a case, C/C++test displays a warning message with a list of missing files.

To generate a coverage report including coverage data for files that were moved to a different location, you can use the CPPTEST_COVERAGE_SRC_ROOT environment variable to map the original path to the local (current) path:

CPPTEST_COVERAGE_SRC_ROOT=/original/path1=/local/path1;/original/path2=/local/path2;...

You can use '*' as an accepted wildcard in the original path. For example:

CPPTEST_COVERAGE_SRC_ROOT=/*/path=/local/path

You can also specify a list of path mappings in a list file (*.lst) and set its location as the value. For example:

CPPTEST_COVERAGE_SRC_ROOT=/path/mapping.lst

Each item in the *.lst file is treated as a separate entry.

Example

In the following example the foo.cpp file was instrumented for coverage and moved to another location.

  • Original location of the instrumented file: /home/server/project-123/foo.cpp
  • Current location of the instrumented file (location at the time when the report is being generated): /home/devel/project/foo.cpp

To generate a coverage report including coverage data for the foo.cpp file:

  1. Define the path mapping using CPPTEST_COVERAGE_SRC_ROOT environment variable, for example:
    > export CPPTEST_COVERAGE_SRC_ROOT=/home/server/project-123=/home/devel/project
  2. Generate the coverage report.

How can I fail the build if code could not be instrumented for code coverage?

By default, when a file cannot be successfully instrumented, the original (non-instrumented) version of that file is used in a build and warning is displayed. To fail the build if one or more source files cannot be instrumented for coverage, use the -disable-auto-recovery-mode option.

Example

cpptestcc -disable-auto-recovery-mode [. . .]

How can I collect coverage for files compiled more than once during a build?

By default, C/C++test stores coverage data for one compilation of each source file in a build. As a result, in rare scenarios when a source file is compiled more than once during a build, C/C++test only stores coverage data for the last compilation of that source file. This may result in an incomplete coverage report with a warning when generating the report: "Coverage report may be incomplete as some information about the code structure is missing in the current workspace." To enable storing multiple variants of coverage data for the same source file (one variant for each compilation during the build), use the -coverage-data-variants option.

Be sure that different compilations of the same source file do not introduce conflicting code ( for example, different variants of the same function) – this is an unsupported scenario.

Example

cpptestcc -coverage-data-variants [. . .]

Can I collect coverage for 'constexpr' functions?

C/C++test will not apply code instrumentation to 'constexpr' functions. As a result, code coverage analysis will not be performed for such functions. This limitation applies also for the following cases:

  • 'constexpr' functions which are used in a 'non-constexpr' context
  • functions which are implicitly treated as 'constexpr', for example, lambda expressions in C++17
  • functions declared with C++20 'consteval' specifier


  • No labels