Main Content

View Coverage Results for Custom C/C++ Code in S-Function Blocks

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:

  • Enable support for S-Function coverage. For more information, see Coverage for Custom C/C++ Code in Simulink Models.

  • Run simulation and view the coverage report.

    The coverage results for S-Function blocks can be viewed in the same report as the rest of the model. For each S-Function block, the report links to a detailed coverage report for the C/C++ code in the block.

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

  1. In the coverage report, view the coverage metrics for the S-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 TitlePurpose
    Analysis informationContains information such as time when model was created and last modified, and file size.
    TestsContains information about the simulation such as start and end time.
    SummaryContains 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 TypeLabel

    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
    DetailsContains coverage information about the statements that receive condition, decision or MCDC coverage. The information is grouped by file and function.
    CodeContains 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.

Related Topics