Create model coverage test specification object
Use cvtest
to create a test specification object that stores
model coverage settings. Pass the cvtest
object to the
cvsim
function to execute coverage analysis based on your
settings.
creates
a cvto
= cvtest(root
)cvtest
object with default coverage settings.
root
can be the name of a model or the handle to a
model. root
can also be the name or handle to a subsystem
within the model, in which case only the specified subsystem and its descendents
are analyzed for coverage.
root
— Name or handle of model or path to subsystemcharacter array
| string array
Model name or handle, or path to a subsystem, specified as a character array or string array.
id
— Internal Model IDscalar
This property is read-only.
Internal model ID, returned as a scalar.
modelcov
— Internal Coverage Configuration IDscalar
This property is read-only.
Internal coverage configuration ID, returned as a scalar.
rootPath
— Name or handle of system to analyzecharacter array
| string array
This property is read-only.
Name of the system you specified to analyze, returned as a character array or string array.
Data Types: char
| string
label
— Test labelcharacter array
| string array
Test label, specified as a character array or a string array. This label appears in the coverage report as the test name.
Data Types: char
| string
setupCmd
— Command executed in base MATLAB workspace before simulationcharacter array
| string array
Command executed in base MATLAB workspace before simulation, specified as a character array or string array.
The setup command is executed before each simulation.
Data Types: char
| string
settings
— Coverage settingsstructure
Types of coverage to collect, specified as a structure.
settings
includes the following fields:
Property | Description | Values |
---|---|---|
| Enable decision coverage data. |
|
| Enable condition coverage data. |
|
| Enable modified condition decision coverage (MCDC) data. If |
|
| Enable coverage data from Simulink® Design Verifier™ blocks. |
|
| Enable coverage data for lookup tables. |
|
| Enable signal range data. |
|
| Enable signal size data. |
|
| Enable saturation on integer overflow coverage data. |
|
| Enable relational boundary coverage data. Use
For more information, see Relational Boundary Coverage |
|
options
— Advanced coverage optionsstructure
Advanced coverage options, specified as a structure.
options
includes the following fields:
Property | Description | Values |
---|---|---|
| Relative tolerance for relational boundary coverage. For more information, see Relational Boundary Coverage. |
|
| Absolute tolerance for relational boundary coverage. For more information, see Relational Boundary Coverage. |
|
| Whether to restrict model coverage recording to a specified simulation time interval. Use
For more information, see Specify Coverage Options |
|
| When to start recording coverage. Specify this property if
|
|
| When to stop recording coverage. Specify this property if
|
|
| Whether to record coverage for blocks flagged with the Block Reduction parameter.
For more information, see Block reduction |
|
| Which MCDC definition to apply to the model, specified as one of the following options:
For more information, see Modified Condition and Decision Coverage (MCDC) Definitions in Simulink Coverage. |
|
filter
— Coverage filterstructure
Coverage filter, specified as a structure.
filter
has one field,
filter.fileName
.
filter.fileName
is the name of a coverage filter
file to apply to coverage analysis, specified as a character array or string
array.
For more information, see Coverage Filter Rules and Files
modelRefSettings
— Model reference settingsstructure
(default)Model reference settings, specified as a structure.
modelRefSettings
includes the following
fields:
Property | Description | Values |
---|---|---|
| Model reference coverage setting, specified as one of the following options:
|
|
| Whether to exclude the top model from coverage
analysis, specified as a numeric or logical |
|
| Referenced models to exclude from coverage analysis, specified as a single character or string array of comma-separated model names. To use
this field, set
|
|
emlSettings
— Whether to collect coverage for external program files called by MATLAB functionsstructure
Whether to collect coverage for external program files called by MATLAB functions in your model, specified as a structure.
emlSettings
has one field,
emlSettings.enableExternal
.
emlSettings.enableExternal
is whether to collect
external program files called by MATLAB functions, specified as a numeric or logical 1
(true)(default)
or 0 (false)
.
sfcnSettings
— Whether to collect coverage for C/C++ S-Function blocksstructure
(default)Whether to collect coverage for C/C++ S-Function blocks in your model, specified as a structure.
sfcnSettings
has one field,
sfcnSettings.enableSfcn
.
sfcnSettings.enableSfcn
is whether to collect
coverage S-Function coverage, specified as a logical 1
(true)(default)
or 0 (false)
.
For more information, see S-Function.
cvtest
ObjectIn this example, you create a cvtest
object for the
Adjustable Rate Limiter block in the
slvnvdemo_ratelim_harness
model. Simulate the model
to get decision coverage and saturation on integer overflow coverage
data.
Open the slvnvdemo_ratelim_harness
model and define the test object
using cvtest
.
open_system('slvnvdemo_ratelim_harness'); testObj = cvtest(['slvnvdemo_ratelim_harness', ... '/Adjustable Rate Limiter']); testObj.label = 'Gain within slew limits';
Add a setup command to testObj
. The setup command is executed in the
base MATLAB workspace before running the coverage analysis. In this case,
the setup command loads data into the workspace that is required for the
simulation.
testObj.setupCmd = ... 'load slvnvdemo_ratelim_harness_data.mat';
To collect decision coverage and saturation on integer overflow coverage, enable the
decision
and
overflowsaturation
fields in the
settings
structure by setting the fields to
1
.
testObj.settings.decision = 1; testObj.settings.overflowsaturation = 1;
Finally, simulate the model with the coverage analysis by providing the
cvtest
object to the cvsim
function.
cvdo = cvsim(testObj);