User`s guide
Model Objects That Receive Coverage
16-25
C/C++ S-Function
Model coverage is supported for C/C++ S-Functions. The coverage report for the model
contains results for each instance of an S-Function block in the model. The results for an
S-Function block link to a separate coverage report for the C/C++ code in the block.
To generate coverage report for S-Functions:
1
When creating the S-Functions, enable support for coverage. For more information,
see “Make S-Function Compatible with Model Coverage”.
2
When generating the coverage report, enable support for S-Functions. For more
information, see “Generate Coverage Report for S-Function”.
The following coverage types are reported for S-Functions:
• “Cyclomatic Complexity”
• “Condition Coverage (CC)”
• “Decision Coverage (DC)”
• “MCDC Coverage”
• Percentage of statements covered
The coverage data for S-Function blocks is obtained in the following way:
• The coverage result for a block is a weighted average of the result over all files in the
block.
For instance, an S-Function block has two files, file1.c and file2.c. The decision
coverage for file1.c is 75% (3/4 outcomes covered) and that for file2.c is 50%
(10/20 outcomes covered). The decision coverage for the block is 13/24 ≈ 54 %.
• For each file, the coverage result is a weighted average of the result over all functions
in the file.
• For each function, the coverage result is a weighted average of the result over all
statements in the function that receive that coverage.
Note: Model coverage for S-Functions have the following restrictions:
• Only Level-2 C/C++ S-Functions are supported for coverage. For an example of a
level-2 C S-Function, see “Basic C MEX S-Function”.