relationalboundaryinfo
Retrieve relational boundary coverage from cvdata
object
Syntax
Description
returns relational boundary coverage results from the covInfo
= relationalboundaryinfo(cvdo
,modelObject
)cvdata
object
cvdo
for the model object specified by object
and its descendants.
returns relational boundary coverage results from the covInfo
= relationalboundaryinfo(cvdo
,modelObject
,simMode
)cvdata
object
cvdo
for the model object specified by
modelObject
and its descendants for the simulation mode
simMode
.
returns relational boundary coverage results from the covInfo
= relationalboundaryinfo(cvdo
,modelObject
,ignoreDescendants
)cvdata
object
cvdo
for the model object specified by
modelObject
and, depending on the value of
ignoreDescendants
, descendant objects.
[
returns relational boundary coverage results from the covInfo
,description
]
= relationalboundaryinfo(cvdo
,modelObject
)cvdata
object
cvdo
for the model object specified by
modelObject
, and textual descriptions of each coverage
outcome.
Examples
This example shows how to collect relational boundary coverage information for a Saturation block in a model. For more information on blocks supported for relational boundary coverage, see Model Objects That Receive Coverage.
Open the slvnvdemo_cv_small_controller
model.
Create a model coverage test specification object for the model.
openExample('slvnvdemo_cv_small_controller'); open_system('slvnvdemo_cv_small_controller'); testObj = cvtest('slvnvdemo_cv_small_controller');
In the model coverage test specification object, activate relational boundary coverage.
testObj.settings.relationalop = 1;
Simulate the model and collect coverage results in a cvdata
object.
dataObj = cvsim(testObj);
Obtain relational boundary coverage results for the Saturation block in slvnvdemo_cv_small_controller
.
The coverage results are stored in a two-element vector of the form [covered_outcomes
total_outcomes]
.
blockHandle = get_param('slvnvdemo_cv_small_controller/Saturation','Handle'); [covResults,covDesc] = relationalboundaryinfo(dataObj,blockHandle)
covResults = 2 4 covDesc = isFiltered: 0 decision: [1x2 struct]
The field decision
is a 1 X 2
structure.
Each element of decision
corresponds to a relational
operation in the block. The Saturation block
contains two comparisons. The first comparison is with a lower limit
and the second with an upper limit. Therefore, decision
is
a 2-element structure.
View the first operation in the block that receives relational
boundary coverage. For the Saturation block, the first
relational operation is input > lowerlimit
.
covDesc.decision(1)
ans = outcome: [1x2 struct] text: 'input - lowerlimit' isFiltered: 0 filterRationale: ''
The text
field shows the two operands. The isFiltered
field
is set to 1 if the block is filtered from relational boundary coverage.
For more information, see Coverage Filtering.
View results for the first relational operation in the block.
for(i=1:2) covDesc.decision(1).outcome(i) end
ans = isActive: 1 execCount: 0 text: '[-tol..0]' ans = isActive: 1 execCount: 0 text: '(0..tol]'
View the second operation in the block that receives relational
boundary coverage. For the Saturation block, the second
relational operation is input < upperlimit
.
covDesc.decision(2)
ans = outcome: [1x2 struct] text: 'input - upperlimit' isFiltered: 0 filterRationale: ''
View results for the second relational operation in the block.
for(i=1:2) covDesc.decision(2).outcome(i) end
ans = isActive: 1 execCount: 1 text: '[-tol..0)' ans = isActive: 1 execCount: 2 text: '[0..tol]'
Open the example and load the model.
openExample("slcoverage/RetrieveCodeCoverageResultsExample");
Use the
setupSILCoverage
function to configure the model for code coverage analysis. The output is aSimulink.SimulationInput
object.simIn = setupSILCoverage("slvnvdemo_counter_harness");
Simulate the model.
simOut = sim(simIn);
To retrieve coverage results for the generated code that represents a specific block, use the block path. For example, retrieve the relational boundary coverage results for the Relational Operator block named
upper GE input
by passing the block path relative to the top model.covDataSIL = simOut.covdata; relboundBlockSIL = relationalboundaryinfo(covDataSIL,... "slvnvdemo_counter/upper GE input")
relboundBlockSIL = 1 2
To retrieve coverage results for a function in the generated code, use a cell array that contains the generated source file name and function name. For example, retrieve the relational boundary coverage results for the function
slvnvdemo_counter
located in the source fileslvnvdemo_counter.c
.relboundSILFunction = relationalboundaryinfo(covDataSIL,... {"slvnvdemo_counter.c","slvnvdemo_counter"})
relboundSILFunction = 2 4
Open the example and load data into the workspace.
openExample("slcoverage/RetrieveSFunCoverageResultsExample"); load slcoverage_lct_data.mat
Use the
setupSFcnCoverage
function to configure the model for coverage analysis. The output is aSimulink.SimulationInput
object.simIn = setupSFcnCoverage("slcoverage_lct_bus");
Simulate the model.
simOut = sim(simIn);
To retrieve coverage results for an S-function, use the
relationalboundaryinfo
function and specify a cell array that contains the handle or full path of the block, followed by the file name of the S-function source file. Optionally, you can also specify a specific function inside that source file. For this example, retrieve the relational boundary coverage results for the function namedcounterbusFcn
in the S-function filecounterbus.c
, which the S-Function blockslcoverage_sfun_counterbus
calls. The S-Function block is inside theTestCounter
subsystem in the modelslcoverage_lct_bus
.covDataSFcn = simOut.covdata; relboundSFun = relationalboundaryinfo(covDataSFcn,... {"slcoverage_lct_bus/TestCounter/slcoverage_sfun_counterbus",... "counterbus.c","counterbusFcn"})
relboundSFun = 4 6
Input Arguments
Coverage data, specified as a cvdata
object.
Data Types: cvdata
Model object, specified as a character array, string array, Simulink handle, Stateflow ID, or cell array.
To specify a model object, such as a block or a Stateflow chart, use one of these formats:
Object Specification | Description |
---|---|
| Full path to a model or block |
| Handle to a model or block |
| Handle to a Simulink API object |
| Stateflow ID |
| Handle to a Stateflow API object from a singly instantiated Stateflow chart |
| Cell array with the path to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart |
| Cell array with the path to a Stateflow chart or subchart and a Stateflow object API handle contained in that chart or subchart |
| Cell array with a handle to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart |
To specify an S-Function block or its contents, use one of these formats:
Object Specification | Description |
---|---|
| Cell array with the path to an S-Function block and the name of a source file |
| Cell array with an S-Function block handle and the name of a source file |
| Cell array with the path to an S-Function block, the name of a source file, and a function name |
| Cell array with an S-Function block handle, the name of a source file, and a function name |
To specify a code coverage result, such as coverage data collected during software-in-the-loop (SIL) or processor-in-the-loop (PIL) analysis, use one of these formats:
Object Specification | Description |
---|---|
| Cell array with the name of a source file and a function name |
| Cell array with a model name or model handle and the name of a source file |
| Cell array with a model name or model handle, the name of a source file, and a function name |
Data Types: char
| string
| cell
| Stateflow.State
| Stateflow.Transition
Simulation mode during coverage analysis, specified as one of these options:
Object Specification | Description |
---|---|
| Model in normal simulation mode. |
| Model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode. |
| Model reference in SIL or PIL simulation mode. |
| Model reference in SIL or PIL simulation mode with the code interface set to top model. |
Data Types: char
| string
Whether to ignore descendants in coverage results, specified as a numeric or logical
1 (true)
or 0 (false)
, where:
0 (false)
includes coverage results of descendant objects.1 (true)
ignores coverage results of descendant objects.
Data Types: single
| double
| logical
Output Arguments
Coverage information, returned as a two-element array of the form
[covered_outcomes, total_outcomes]
if cvdo
contains relational boundary coverage data, or an empty array if it does not.
covered_outcomes | Number of relational boundary outcomes satisfied for
object |
total_outcomes | Total number of relational boundary outcomes for
object |
Data Types: double
Textual description of coverage outcomes for the model component
specified by object
, returned as a structure
array. Depending on the types of model coverage collected, the structure
array can have different fields. If only relational boundary coverage
is collected, the structure array contains the following fields:
isFiltered |
| ||||||
decision.text | Character vector or string of the form:
| ||||||
decision.outcome | Structure array containing two fields for each coverage outcome:
| ||||||
decision.isFiltered |
| ||||||
decision.filterRationale | Rationale for filtering the model component specified
by |
Data Types: struct
Version History
Introduced in R2014b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)