View Coverage Results for Custom C/C++ Code in S-Function Blocks - MATLAB & Simulink (original) (raw)

Main Content

This example shows how to view coverage results for the C/C++ code in S-Function blocks in your model. To view coverage results for the C/C++ code in the blocks:

To view the full code coverage report used in this example, follow the steps inCoverage for S-Functions.

  1. In the coverage report, view the coverage metrics for theS-Function block.
    Coverage report for the S Function block shows a cyclomatic complexity of 3, 67% decision coverage (4 out of 6 decision outcomes satisfied), 75% condition coverage (3 out of 4 condition outcomes satisfied), and 50% MCDC coverage (1 out of 2 MCDC outcomes satisfied).
    For more information on the coverage report format, see Top-Level Model Coverage Report.
  2. Select the Detailed Report link. The code coverage report for the S-Function block opens.
  3. Select each of the links in Table Of Contents to navigate to various sections of the report.
    Section Title Purpose
    Analysis information Contains information such as time when model was created and last modified, and file size.
    Tests Contains information about the simulation such as start and end time.
    Summary Contains coverage information about the files and functions in the S-Function block. For each file and function, the percentage coverage is displayed. The coverage types relevant for the code are the following:
    Coverage Type Label
    Cyclomatic Complexity Complexity
    Condition Coverage Condition.
    Decision Coverage Decision
    Modified Condition/Decision Coverage (MCDC) MCDC
    Relational Boundary Coverage Relational Boundary
    Percentage of statements covered Stmt
    Details Contains coverage information about the statements that receive condition, decision or MCDC coverage. The information is grouped by file and function.
    Code Contains the C/C++ code. Statements that are not covered are highlighted in pink.
  4. In the Summary section, select each file or function name to see details of coverage for statements in the file or function.
    Code coverage report summary shows colored bars for each metric. Blue on the bar indicates satisfied coverage, and pink indicates missing coverage. The file counterbus.c shows 75% decision coverage, 67% condition coverage, 50% MCDC, and 90% statement coverage.
  5. The condition, decision or MCDC outcomes that were not tested during simulation are highlighted in pink. Within the details for a file or function, scroll down to note these cases and investigate them further.
    Coverage report shows the condition input GE lower is true for 140 steps, but false for 0, resulting in incomplete coverage.
  6. To obtain an overview of the statements that were not covered, navigate to the Code section. This section contains your code with the uncovered statements highlighted in pink.
    Code snippet for a function that has line 22 highlighted pink, indicating that line 22 is missing coverage.

See Also

Topics