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.

    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


    Condition Coverage


    Decision Coverage


    Modified Condition/Decision Coverage (MCDC)


    Relational Boundary Coverage

    Relational Boundary

    Percentage of statements covered

    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.

  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.

  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.

Related Topics