...
<INSTALL_DIR>/bin/cpptestcc
- A coverage tool that integrates into your build process to instrument your application to collect raw coverage data.<INSTALL_DIR>/bin/engine/coverage/runtime
- A coverage runtime library that needs to be integrated with the instrumented application.
Collecting coverage with cpptestcc
involves three phases:
- Instrumenting the application by integrating the
cpptestcc
tool into your build. - Executing instrumented code and collecting raw coverage data.
- Reviewing the coverage with C/C++test by importing the raw coverage data into C/C++test with a built-in test configuration.
...
Add the path to
<INSTALL_DIR>/bin
the to thePATH
system variable to enable execution of thecpptestcc
tool.- Update your compilation command to include the
cpptestcc
executable as a prefix to the compiler command using--
as a separator. For example:Original compilation command line
Code Block cc -I app/includes -D defines -c source.cpp
Updated compilation command line
Code Block cpptestcc -compiler gcc_7 -line-coverage -- cc -I app/includes -D defines -c source.cpp
Info At a minimum, the cpptestcc
tool requires the following parameters to be configured on the command line:- a compiler identifier:
-compiler <COMPILER_ID>
- a coverage metric (for example,
-decision-coverage
)See Command Line Reference for cpptestcc for information about other options.
- Update your linker command with the path to the pre-built coverage runtime library shipped with C/C++test to add the library to your application. For example:
Original command line
Code Block lxx -L app/lib app/source.o somelib.lib -o app.exe
Updated command line
Code Block lxx -L app/lib app/source.o somelib.lib [INSTALL_DIR]/bin/engine/coverage/runtime/lib/cpptest.lib -o app.exe
Info icon false title Important If the coverage runtime library is linked as a shared (dynamic-load) library, you must ensure that it can be loaded when the instrumented application is started. This typically requires adding
<INSTALL_DIR>/bin
/engine/coverage/runtime/bin
to thePATH
environment variable (on Windows) or<INSTALL_DIR>/bin
/engine/coverage/runtime/lib
to theLD_LIBRARY_PATH
environment variable (on Linux).Info icon false C/C++test provides the pre-built coverage runtime library for native Windows and Linux applications. For cross-platform and embedded testing, the runtime library needs to built from sources that are available in
<INSTALL_DIR>
/bin/engine/coverage/runtime.
See Coverage Runtime Library for details. - Build the application. When instrumenting the code,
cpptestcc
creates the.cpptest/cpptestcc
folder where important coverage-related data ("coverage maps") are stored. By default, the folder is located in the working directory of the current compilation. You can change the default location using the-workspace <path>
option; see Command Line Reference for cpptestcc for details. - Run the application. The coverage data ("coverage log") will be stored it the
cpptest_results.clog
file. - In your IDE where C/C++test is installed, create a new project that includes all the source files of the application.
Ensure that the files and all the paths remain unchanged. - Select the project and choose Parasoft> Test Configurations> Utilities> Load Application Coverage from your IDE menu to import the coverage data (see Importing the Coverage Data for details).
- Review the coverage information (see Reviewing Coverage Information).
...
File | Description |
---|---|
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/cpptest.a | 32-bit import library to be used with Cygwin GNU GCC compilers. To be added to linking command line. |
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/cpptest64.a | 64-bit import library to be used with Cygwin GNU GCC compilers. To be added to linking command line. |
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/cpptest.lib | 32-bit import library to be used with Microsoft Visual C++ compilers. To be added to linking command line. |
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/cpptest64.lib | 64-bit import library to be used with Microsoft Visual C++ compilers. To be added to linking command line. |
<INSTALL_DIR>/bin/engine/coverage/runtime/bin/cpptest.dll | 32-bit dynamic-link library. <INSTALL_DIR> /bin/engine/coverage/runtime/bin should be added to PATH environmental variable. |
<INSTALL_DIR>/bin/engine/coverage/runtime/bin/cpptest64.dll | 64-bit dynamic-link library. <INSTALL_DIR> /bin/engine/coverage/runtime/bin should be added to PATH environmental variable. |
Linux (x86 and x86-64)
File | Description |
---|---|
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/libcpptest.so | 32-bit shared library. To be added linking command line. <INSTALL_DIR> /bin/engine/coverage/runtime/lib should be added to LD_LIBRARY_PATH |
<INSTALL_DIR>/bin/engine/coverage/runtime/lib/libcpptest64.so | 64 bit shared library. To be added linking command line. <INSTALL_DIR>/bin/engine/coverage/runtime/lib should be added to LD_LIBRARY_PATH |
...
- Locate the linker command line in your build scripts
Modify the build scripts so that the coverage runtime library is specified somewhere in the linker command line - preferably after all object files. For example:
Code Block $(LXX) $(PRODUCT_OBJ) $(OFLAG_EXE)$(PROJ_EXECUTABLE) $(LXXFLAGS) $(SYSLIB) $(EXECUTABLE_LIB_LXX_OPTS) <INSTALL_DIR>/bin/engine/coverage/runtime/lib/cpptest.lib
Ensure that the path to the
lib
directory is added to thePATH
environment variable so that the library can be located when the tested program is started. You may also consider copyingcpptest.dll
(orcpptest64.dll
) file to the same directory as your executable file or to another location that is scanned for dynamic-link libraries during tested application startup.
...
- Locate the linker command line in your build scripts
Modify the build scripts so that the coverage runtime library is specified somewhere in the linker command line - preferably after all object files. For example:
Code Block $(LXX) $(PRODUCT_OBJ) $(OFLAG_EXE)$(PROJ_EXECUTABLE) $(LXXFLAGS) $(SYSLIB) $(EXECUTABLE_LIB_LXX_OPTS) -L <INSTALL_DIR>/bin/engine/coverage/runtime/lib -lcpptest
Note that the
-L
and-lcpptest
options are added.- Ensure that the path to the
lib
directory is added to theLD_LIBRARY_PATH
environmental variable to allow the tested executable to find the path to the shared library.
...