conditioninfo
Retrieve condition coverage information fromcvdata
object
Syntax
Description
returns the condition coverage results from thecovInfo
= conditioninfo(cvdo
,modelObject
)cvdata
objectcvdo
for the model component specified bymodelObject
.
returns the condition coverage results from thecovInfo
= conditioninfo(cvdo
,modelObject
,simMode
)cvdata
objectcvdo
for the simulation modesimMode
.
returns the condition coverage results forcovInfo
= conditioninfo(cvdo
,modelObject
,ignoreDescendants
)modelObject
, including or ignoring descendant objects based on the value ofignoreDescendants
.
[
returns the condition coverage results and textual descriptions for each condition incovInfo
,description
] = conditioninfo(cvdo
,modelObject
)modelObject
.
Examples
View Condition Coverage Data
This example shows how to view condition coverage for a block in your model.
Load the model.
modelName ='slvnvdemo_cv_small_controller'; load_system(modelName);
Configure the coverage settings for the model by using aSimulink.SimulationInput
object.
simIn = Simulink.SimulationInput(modelName); simIn = simIn.setModelParameter('CovEnable','on'); simIn = simIn.setModelParameter('CovMetricStructuralLevel','MCDC'); simIn = simIn.setModelParameter('CovSaveSingleToWorkspaceVar','on'); simIn = simIn.setModelParameter('CovSaveName','covData');
模拟模型by passingsimIn
as the input tosim
.
simOut = sim(simIn); covData = simOut.covData;
View the condition coverage results for the Logic block in the Gain subsystem by callingconditioninfo
with the block path.
condCov = conditioninfo(covData,[modelName,'/Gain/Logic'])
condCov = 2 4
conditioninfo
returns an array with two scalars. The first value is the number of satisfied condition outcomes, and the second value is the number of total condition outcomes. Use these to determine the percentage of satisfied condition outcomes for the Logic block.
percentCondCov = 100 * condCov(1) / condCov(2)
percentCondCov = 50
Input Arguments
cvdo
—Coverage data
cvdata
object
Coverage data, specified as acvdata
object.
Data Types:cvdata
modelObject
—Model object
character array
|string array
|万博1manbetx®handle
|Stateflow®ID
|cell array
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 anS-Functionblock and the name of a source file |
|
Cell array with anS-Functionblock handle and the name of a source file |
|
Cell array with the path to anS-Functionblock, the name of a source file, and a function name |
|
Cell array with anS-Functionblock 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
simMode
—Simulation mode
character array
|string array
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
ignoreDescendants
—Whether to ignore descendants in coverage results
false
or0
(default) |true
or1
Whether to ignore descendants in coverage results, specified as a numeric or logical1 (true)
or0 (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
covInfo
— Coverage information
scalar
Coverage information, returned as a two-element array of the form[covered_outcomes,total_outcomes]
ifcvdo
contains condition coverage data, or an empty array if it does not.
covered_outcomes |
Number of condition outcomes satisfied formodelObject |
total_outcomes |
Total number of condition outcomes formodelObject |
Data Types:double
description
— Condition coverage description
structure
Condition coverage description, returned as a structure with the following fields:
isFiltered
— Block exclusion flag
0
|1
Block exclusion flag, returned as1
if the block is excluded and0
if it is not.
Data Types:
filterRationale
— Block coverage filter rationale
character array
Block coverage filter rationale, returned as a character array.
Data Types:char
justifiedCoverage
— Number of justified coverage objective outcomes
scalar
Number of justified coverage objective outcomes, returned as a scalar double.
Data Types:double
isJustified
— Block justification flag
0
|1
Block justification flag, returned as1
if the block is justified or0
if it is not.
Data Types:double
condition
— Information for individual condition outcomes
structure
Information for individual condition outcomes, returned as a structure with the following fields:
isFiltered
— Condition exclusion flag
0
|1
Condition exclusion flag, returned as1
if the condition is excluded or0
if it is not.
Data Types:double
isJustified
— Condition justification flag
0
|1
Condition justification flag, returned as1
if the condition is justified or0
if it is not.
Data Types:double
filterRationale
— Coverage filter rationale
character array
Coverage filter rationale, returned as a character array.
Data Types:char
text
— Description of condition
character array
Description of the condition, returned as a character array.
Data Types:char
trueCnts
— Number of time steps condition istrue
scalar
Number of time steps the condition istrue
, returned as a scalar.
Data Types:double
falseCnts
— Number of time steps condition isfalse
scalar
Number of time steps the condition isfalse
, returned as a scalar.
Data Types:double
trueOutcomeFilter
— Coverage filter information fortrue
condition outcome
structure array
Coverage filter information for thetrue
condition outcome, returned as a structure array with the following fields:
isFiltered |
Filter flag for the condition outcome, returned as1 if the outcome is filtered or0 if it is not. |
isJustified |
Justification flag for the condition outcome, returned as1 if the outcome is justified or0 if it is not. |
filterRationale |
The filter rationale, returned as a character array. |
Data Types:struct
falseOutcomeFilter
— Coverage filter information forfalse
condition outcome
structure array
Coverage filter information for thefalse
condition outcome, returned as a structure array with the following fields:
isFiltered |
Filter flag for the condition outcome, returned as1 if the outcome is filtered or0 if it is not. |
isJustified |
Justification flag for the condition outcome, returned as1 if the outcome is justified or0 if it is not. |
filterRationale |
The filter rationale, returned as a character array. |
Data Types:struct
trueExecutedIn
— Aggregated coverage test case traceability information
structure array
|[]
聚合informa覆盖测试用例的可追溯性tion, returned as a structure array. If your coverage data does not contain aggregated results from multiple simulations,trueExecutedIn
is an empty array. If your coverage data contains aggregated results,trueExecutedIn
indicates which test runs executed thetrue
condition outcome and has the following fields:
uniqueId |
Unique identifier for thecvdata object created by the test case that executed this condition outcome, returned as a character array. |
analyzedModel |
The name of the model analyzed, returned as a character array. |
description |
The test case description, returned as a character array. |
date |
The date and time of the simulation that created thecvdata object, returned as a character array. |
traceLabel |
The short name of the test case, returned as a character array. |
testRunInfo |
Test details, returned as a structure array. |
testRunInfo.runid |
The identifier of the run that generated the coverage result, returned as a scalar double. |
testRunInfo.runName |
The name of the test case that generated the coverage result, returned as a character array. |
testRunInfo.testId |
Identifying data for the test case that generated the coverage result, returned as a structure array. |
testRunInfo.testId.uuid |
The unique identifier for the test case that generated the coverage result, returned as a character array. |
testRunInfo.testId.contextType |
The test context in which the coverage result was obtained, returned as one of these values:
|
Data Types:struct
falseExecutedIn
— Aggregated coverage test case traceability information
structure array
|[]
聚合informa覆盖测试用例的可追溯性tion, returned as a structure array. If your coverage data does not contain aggregated results from multiple simulations,falseExecutedIn
is an empty array. If your coverage data contains aggregated results,falseExecutedIn
indicates which test runs executed thefalse
condition outcome and has the following fields:
uniqueId |
Unique identifier for thecvdata object created by the test case that executed this condition outcome, returned as a character array. |
analyzedModel |
The name of the model analyzed, returned as a character array. |
description |
The test case description, returned as a character array. |
date |
The date and time of the simulation that created thecvdata object, returned as a character array. |
traceLabel |
The short name of the test case, returned as a character array. |
testRunInfo |
Test details, returned as a structure array. |
testRunInfo.runid |
The identifier of the run that generated the coverage result, returned as a scalar double. |
testRunInfo.runName |
The name of the test case that generated the coverage result, returned as a character array. |
testRunInfo.testId |
Identifying data for the test case that generated the coverage result, returned as a structure array. |
testRunInfo.testId.uuid |
The unique identifier for the test case that generated the coverage result, returned as a character array. |
testRunInfo.testId.contextType |
The test context in which the coverage result was obtained, returned as one of these values:
|
Data Types:struct
Data Types:struct
Data Types:struct
Alternatives
You can also collect condition coverage for a model in the Simulink Editor. Set the model configuration parameters and run the model:
Open the model for which you want to collect condition coverage.
In the Simulink Editor, in theModelingtab, selectModel Settings.
On theCoveragepane of the Configuration Parameters dialog box, selectEnable coverage analysis.
Under覆盖率度量, select
Condition Decision
as the structural coverage level.ClickOKto close the Configuration Parameters dialog box and save your changes.
模拟模型by clickingRun. Review the results.
版本历史
Introduced in R2006b
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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:.
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)