In addition to industry-standard C/C++ code coverage metrics, C/C++test can collect code coverage at the assembly level (also known as object code coverage), which provides visibility into which sections of assembly code were covered during test execution, as well as details on branching points execution.
Unlike C/C++ code coverage, assembly coverage results are not integrated with C/C++test views. Reports are available as external HTML, XML, or CSV files. See Generating the Assembly Coverage Report for more details.
This section provides information on collecting object code coverage in your IDE. For details about Parasoft tools for collecting coverage at the assembly level, see the Parasoft ASMtools documentation shipped with C/C++test in <INSTALL_DIR>/bin/engine/asmtool/manuals
.
Supported Compilers
On Windows
Assembly code coverage is supported for the following GHS compilers:
- Green Hills Software Compiler for PPC v. 4.0.x
- Green Hills Software Compiler for PPC v. 4.2.x
- Green Hills Software Compiler for PPC v. 2017.1.x
C/C++test is preconfigured to collect assembly-level coverage data from Green Hills Software PPC simulator. Contact Parasoft Support for more information if you want to collect object coverage data from on-target tests execution.
On Linux 64-bit:
Assembly code coverage is supported for the following GNU GCC compilers for x86 (32-bit):
- GNU GCC 5.x
- GNU GCC 6.x
- GNU GCC 7.x
- GNU GCC 8.x
Configuring Project Settings
Assuming that your project is configured for unit test execution or application memory monitoring with C/C++test and set up for a supported compiler (see Supported Compilers), no other configuration steps are required.
You can exclude test-harness initializers (added by C/C++test) from the assembly coverage report. Go to Project Properties> Parasoft> C/C++test> Build Settings> Compiler Options and add the following option:
-DCPPTEST_USE_GLOBAL_OBJECTS_TO_INIT_RUNTIME=0
This will disable adding the test-harness initializers to compilation units under test. Instead, C/C++test will generate a separate "test runner" for performing test-harness initialization.
Collecting Assembly Code
C/C++test ships with built-in test configurations for executing unit test cases with assembly coverage monitoring. To view the test configuration settings:
- Choose Parasoft> Test Configurations from your IDE menu.
- Select the following built-in test configuration:
On Windows: Builtin> Embedded Systems> Green Hills Software> Run GHS Tests with Assembly Coverage Monitoring
On Linux: Builtin>Embedded Systems>GNU GCC>Run GNU GCC Tests with Assembly Coverage Monitoring
When you run the test configuration, coverage data is stored in the tested program's memory buffers. When the scheduled tests are executed and test executable exits, the collected coverage information is saved via the defined communication channel (typically, directly to the file).
If the test executable crashes or the memory becomes corrupted, the buffers that store coverage data may become corrupted or may not be saved. For this reason, we recommend reviewing test cases prior to execution and excluding from the testing session all tests that may crash the application.
Generating the Assembly Coverage Report
Assembly coverage reports are generated after test execution in the format specified in the test configuration (see Customizing Report Options). There is no assembly coverage data visible in C/C++test’s coverage view, source code editor, or any other component of the C/C++test UI.
- After executing the test configuration, click Generate Report button.
- Click Preferences and choose HTML (C++test’s Unit Testing details) from the Report Format drop-down menu.
- Apply your settings and click OK to exit the Preferences dialog
- Click OK on the Report & Publish dialog.
The link to the assembly coverage report will be available in the Assembly Coverage column included in the Additional Reports section at the bottom of the main report:
Customizing Report Options
You can customize the format and encoding of the assembly coverage report by modifying the test configuration you will use to execute test cases (see Collecting Assembly Code). Go to General> Test execution flow and configure the following options:
Option Name | Values |
---|---|
Assembly coverage report format | Available formats: html, xml, txt, flattxt, csv The default is html. |
Assembly coverage report encoding | The encoding used for html reports. The default is UTF-8 |
Contact Parasoft Support for more information if you want to collect object coverage data from on-target test execution.
Additional Notes About Assembly Coverage
- Assembly coverage metrics are only supported for the selected compilers (see Assembly Code Coverage). The C/C++test console will print a message to the console if you run assembly coverage monitoring with a project configured for an unsupported compiler.
- Assembly coverage is collected through assembler source code instrumentation generated from C/C++ instrumented code. For this reason, you should not enable other instrumentation features that will make C/C++ instrumented code significantly different from original code. The recommended configuration of instrumentation features is shown in the screenshot below.