coverage for custom c/c code in simulink models
when you record coverage for models containing supported c/c s-functions, matlab function blocks that call external c/c code, c caller blocks with c/c code , or stateflow® charts that integrate custom c/c code for simulation, coverage is recorded for the c/c code within the c/c s-functions, matlab function blocks, or stateflow charts. the coverage results for the custom code can be viewed in the same report as the rest of the model. for each s-function block, matlab function block, or stateflow chart, the report links to a detailed coverage report for the c/c code in the block.
enable code coverage for custom c/c code in matlab function blocks, c caller blocks, and stateflow charts
to enable code coverage for custom c/c code in your simulink® model:
on the simulation target pane of the configuration parameters, select import custom code.
on the simulation target pane of the configuration parameters, select enable custom code analysis.
simulink coverage™ records code coverage for custom c/c code in matlab function blocks, c caller blocks, and stateflow charts.
code coverage for s-functions
make s-function compatible with model coverage
if you use the function, block or function to create your s-functions, adapt your method appropriately to make the s-function compatible with model coverage.
for more information on the three approaches, see .
s-function using legacy_code
function
initialize a matlab® structure with fields that represent legacy code tool properties.
def = legacy_code('initialize')
to enable model coverage, turn on the option
def.options.supportcoverage
.def.options.supportcoverageanddesignverifier = true;
use the structure
def
in the usual way to generate an s-function. for an example, see .
s-function using s-function builder
copy an instance of the s-function builder block from the user-defined functions library in the library browser into the your model.
double-click the block to open the s-function builder dialog box.
on the build info tab, select enable support for coverage.
s-function using mex
function. if you use the mex
function to compile and link your source
files, use the slcovmex
function instead. the
slcovmex
function compiles your source code and also makes it
compatible with coverage.
this function has the same syntax and takes the same options as the
mex
function. in addition, you can provide some options relevant for
model coverage. for more information, see .
generate coverage report for s-function
in the simulink editor, select model settings on the modeling tab.
on the coverage pane of the configuration parameters dialog box, under include in analysis, select c/c s-functions.
when you run a simulation, the coverage report contains coverage metrics for c/c s-function blocks in your model. for each s-function block, the report links to a detailed coverage report for the c/c code in the block.