getCoverageInfo - Retrieve coverage information for Simulink
Design Verifier blocks from cvdata object - MATLAB ([original](https://in.mathworks.com/help/slcoverage/ref/getcoverageinfo.html)) ([raw](?raw))
Retrieve coverage information for Simulink Design Verifier blocks from cvdata
object
Syntax
Description
[[covInfo](#br8ro9s-coverage),[description](#mw%5Fb54c2f9a-8e15-4d56-b70c-92b30f6af280)] = getCoverageInfo([cvdo](#br8ro9s%5Fsep%5Fbrxo2jj-1-cvdo),[modelObject](#br8ro9s%5Fsep%5Fbswieqq-1-object))
collects Simulink® Design Verifier™ coverage for object
, based on coverage results incvdo
. object
is a handle to a block, subsystem, or Stateflow® chart. getCoverageData
returns coverage data only for Simulink Design Verifier library blocks in object
's hierarchy.
[[covInfo](#br8ro9s-coverage),[description](#mw%5Fb54c2f9a-8e15-4d56-b70c-92b30f6af280)] = getCoverageInfo([cvdo](#br8ro9s%5Fsep%5Fbrxo2jj-1-cvdo),[modelObject](#br8ro9s%5Fsep%5Fbswieqq-1-object),[metric](#br8ro9s-metric))
returns coverage data for the block type specified in metric
. If object
does not match the block type,getCoverageInfo
does not return data.
[[covInfo](#br8ro9s-coverage),[description](#mw%5Fb54c2f9a-8e15-4d56-b70c-92b30f6af280)] = getCoverageInfo([cvdo](#br8ro9s%5Fsep%5Fbrxo2jj-1-cvdo),[modelObject](#br8ro9s%5Fsep%5Fbswieqq-1-object),[metric](#br8ro9s-metric),[ignoreDescendants](#br8ro9s%5Fsep%5Fmw%5Ffeb2a172-08b8-4e3b-b2bb-6c8d51d75f21))
returns coverage data about object
, omitting coverage data for its descendant objects if ignoreDescendants
equals1
.
Examples
Get coverage for allProof Objective blocks in Verification Subsystem1
mdl = 'sldvdemo_powerwindow_vs'; openExample(mdl); open_system(mdl); set_param(mdl, 'StopTime', '10') testObj = cvtest(mdl); testObj.settings.designverifier = 1; data = cvsim(testObj); verifSubsys = [mdl '/Verification Subsystem1']; covProof = getCoverageInfo(data, verifSubsys, cvmetric.Sldv.proof)
covProof
is a two-element vector of the form[covered_outcomestotal_outcomes]
showing 1 covered outcome out of 1 total proof objective outcome.
Get coverage for a specific Test Objective block inVerification Subsystem1
mdl = 'sldvdemo_powerwindow_vs'; open_system(mdl) set_param(mdl, 'StopTime', '10') testObj = cvtest(mdl); testObj.settings.designverifier = 1; data = cvsim(testObj); verifSubsys = [mdl '/Verification Subsystem1']; testObjBlock = [verifSubsys '/Test Objective2']; covTest = getCoverageInfo(data, testObjBlock)
covTest
is a two-element vector of the form[covered_outcomes total_outcomes]
showing 0 covered outcomes out of 1 total test objective outcome.
Get coverage data and descriptions for all available metrics recorded inVerification Subsystem1
mdl = 'sldvdemo_powerwindow_vs'; open_system(mdl) set_param(mdl, 'StopTime', '10') testObj = cvtest(mdl); testObj.settings.designverifier = 1; data = cvsim(testObj); verifSubsys = [mdl '/Verification Subsystem1']; [covAll, descrAll] = getCoverageInfo(data, verifSubsys, ... {cvmetric.Sldv.proof, cvmetric.Sldv.test})
covAll
is a cell array with cells corresponding to the objective outcomes for each metric. descrAll
is a cell array with cells corresponding to descriptions of each metric.
covAll{1}
is a two-element vector of the form[covered_outcomes total_outcomes]
showing 1 covered outcomes out of 1 total proof objective outcomes.covAll{2}
is a two-element vector of the form[covered_outcomes total_outcomes]
showing 0 covered outcomes out of 1 total test objective outcomes.
descrAll{1}
is a structure array containing descriptions of each proof objective, and descriptions and execution counts for each outcome. descrAll{2}
is a structure array containing descriptions of each test objective, and descriptions and execution counts for each outcome.
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 |
---|---|
BlockPath | Full path to a model or block |
BlockHandle | Handle to a model or block |
slObj | Handle to a Simulink API object |
sfID | Stateflow ID |
sfObj | Handle to a Stateflow API object from a singly instantiated Stateflow chart |
{BlockPath,sfID} | Cell array with the path to a Stateflow chart or atomic subchart and the ID of an object contained in that chart or subchart |
{BlockPath,sfObj} | Cell array with the path to a Stateflow chart or subchart and a Stateflow object API handle contained in that chart or subchart |
{BlockHandle,sfID} | 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 |
---|---|
{BlockPath,fileName} | Cell array with the path to an S-Function block and the name of a source file |
{BlockHandle,fileName} | Cell array with an S-Function block handle and the name of a source file |
{BlockPath,fileName,functionName} | Cell array with the path to an S-Function block, the name of a source file, and a function name |
{BlockHandle,fileName,functionName} | 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 |
---|---|
{fileName,functionName} | Cell array with the name of a source file and a function name |
{Model,fileName} | Cell array with a model name or model handle and the name of a source file |
{Model,fileName,functionName} | 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
Coverage metric to retrieve, specified as a cvmetric.Sldv
enumeration, or a cell array of enumerations, with values that correspond toSimulink Design Verifier library blocks. If you do not specify a metric,getCoverageInfo
returns coverage information for all available metrics for the specifiedmodelObject.
Data Types: cvmetric.Sldv
Whether to ignore descendants in coverage results, specified as a numeric or logical1 (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]
ifcvdo contains decision coverage data, or an empty array if it does not. If modelObject receives coverage for more than one metric, covInfo
returns a cell array of two-element arrays where each cell corresponds to one metric.
covered_outcomes | Number of decision outcomes satisfied formodelObject |
---|---|
total_outcomes | Total number of decision outcomes formodelObject |
Data Types: double
Coverage description, returned as a structure array with the following fields:
Note
If modelObject receives coverage for more than one metric, description
returns a cell array of structures where each cell contains adescription
structure for one metric.
Block exclusion flag, returned as 1
if the block is excluded and 0
if it is not.
Data Types: double
Block coverage filter rationale, returned as a character array.
Data Types: char
Number of justified coverage objective outcomes, returned as a scalar double.
Data Types: double
Block justification flag, returned as 1
if the block is justified or 0
if it is not.
Data Types: double
Test objective information, returned as a structure with the following fields:
Text, returned as the character array'T'
.
Data Types: char
Number of time steps the objective is true, returned as a scalar double.
Data Types: double
Data Types: struct
Data Types: struct
Alternatives
Use the coverage settings to collect and display coverage results for Simulink Design Verifier library blocks:
- Open the model.
- In the Model Editor, select Model Settings on theModeling tab.
- On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.
- Under Coverage metrics, select Objectives and constraints.
- Click OK to close the Configuration Parameters dialog box and save your changes.
- Simulate the model and review the results.
Version History
Introduced in R2009b