Main Content

conditioninfo

Retrieve condition coverage information from cvdata object

Description

covInfo = conditioninfo(cvdo,modelObject) returns the condition coverage results from the cvdata object cvdo for the model component specified by modelObject.

covInfo = conditioninfo(cvdo,modelObject,simMode) returns the condition coverage results from the cvdata object cvdo for the simulation mode simMode.

covInfo = conditioninfo(cvdo,modelObject,ignore_descendants) returns the condition coverage results for modelObject, including or ignoring descendant objects based on the value of ignore_descendants.

[covInfo,description] = conditioninfo(cvdo,modelObject) returns the condition coverage results and textual descriptions for each condition in modelObject.

Examples

collapse all

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 a Simulink.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');

Simulate the model by passing simIn as the input to sim.

simOut = sim(simIn);
covData = simOut.covData;

View the condition coverage results for the Logic block in the Gain subsystem by calling conditioninfo 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

collapse all

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, for example a block or a Stateflow chart, use one of the following formats:

Object SpecificationDescription

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 the following formats:

Object SpecificationDescription

{BlockPath, fName}

Cell array with the path to an S-Function block and the name of a source file

{BlockHandle, fName}

Cell array with an S-Function block handle and the name of a source file

{BlockPath, fName, funName}

Cell array with the path to an S-Function block, the name of a source file, and a function name

{BlockHandle, fName, funName}

Cell array with an S-Function block handle, the name of a source file an a function name

To specify a code coverage result, for example coverage data collected during software-in-the-loop (SIL) or processor-in-the-loop (PIL) analysis, use one of the following formats:

Object SpecificationDescription

{fileName, funName}

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, funName}

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 the following:

Object SpecificationDescription

'Normal'

Model in normal simulation mode.

'SIL' (or 'PIL')

Model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode.

'ModelRefSIL' (or 'ModelRefPIL')

Model reference in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode.

'ModelRefTopSIL' (or 'ModelRefTopPIL')

Model reference in software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation mode with the code interface set to top model.

Data Types: char | string

Whether to ignore descendants in coverage results, specified as 0 or 1, where:

  • 0 includes coverage results of descendant objects.

  • 1 ignores coverage results of descendant objects.

Data Types: single | double

Output Arguments

collapse all

Coverage information, returned as a two-element array of the form [covered_outcomes,total_outcomes] if cvdo contains condition coverage data, or an empty array if it does not.

covered_outcomesNumber of condition outcomes satisfied for modelObject
total_outcomesTotal number of condition outcomes for modelObject

Data Types: double

Condition coverage description, returned as a structure with the following fields:

Block exclusion flag, returned as 1 if the block is excluded and 0 if it is not.

Data Types:

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

Information for individual condition outcomes, returned as a structure array with the following fields:

Condition exclusion flag, returned as 1 if the condition is excluded or 0 if it is not.

Data Types: double

Condition justification flag, returned as 1 if the condition is justified or 0 if it is not.

Data Types: double

Coverage filter rationale, returned as a character array.

Data Types: char

Description of the condition, returned as a character array.

Data Types: char

Number of time steps the condition is true, returned as a scalar.

Data Types: double

Number of time steps the condition is false, returned as a scalar.

Data Types: double

Coverage filter information for the true condition outcome, returned as a structure array with the following fields:

isFilteredFilter flag for the condition outcome, returned as 1 if the outcome is filtered or 0 if it is not.
isJustifiedJustification flag for the condition outcome, returned as 1 if the outcome is justified or 0 if it is not.
filterRationaleThe filter rationale, returned as a character array.

Data Types: struct

Coverage filter information for the false condition outcome, returned as a structure array with the following fields:

isFilteredFilter flag for the condition outcome, returned as 1 if the outcome is filtered or 0 if it is not.
isJustifiedJustification flag for the condition outcome, returned as 1 if the outcome is justified or 0 if it is not.
filterRationaleThe filter rationale, returned as a character array.

Data Types: struct

Aggregated coverage test case traceability information, 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 the true condition outcome and has the following fields:

uniqueIdUnique identifier for the cvdata object created by the test case that executed this condition outcome, returned as a character array.
analyzedModelThe name of the model analyzed, returned as a character array.
descriptionThe test case description, returned as a character array.
dateThe date and time of the simulation that created the cvdata object, returned as a character array.
traceLabelThe short name of the test case, returned as a character array.
testRunInfoTest details, returned as a structure array.
testRunInfo.runidThe identifier of the run that generated the coverage result, returned as a scalar double.
testRunInfo.runNameThe name of the test case that generated the coverage result, returned as a character array.
testRunInfo.testIdIdentifying data for the test case that generated the coverage result, returned as a structure array.
testRunInfo.testId.uuidThe 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:

'RE' for the Coverage Results Explorer

'ST' for the Simulink Test™ Manager

Data Types: struct

Aggregated coverage test case traceability information, 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 the false condition outcome and has the following fields:

uniqueIdUnique identifier for the cvdata object created by the test case that executed this condition outcome, returned as a character array.
analyzedModelThe name of the model analyzed, returned as a character array.
descriptionThe test case description, returned as a character array.
dateThe date and time of the simulation that created the cvdata object, returned as a character array.
traceLabelThe short name of the test case, returned as a character array.
testRunInfoTest details, returned as a structure array.
testRunInfo.runidThe identifier of the run that generated the coverage result, returned as a scalar double.
testRunInfo.runNameThe name of the test case that generated the coverage result, returned as a character array.
testRunInfo.testIdIdentifying data for the test case that generated the coverage result, returned as a structure array.
testRunInfo.testId.uuidThe 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:

'RE' for the Coverage Results Explorer

'ST' for the Simulink Test Manager

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:

  1. Open the model for which you want to collect condition coverage.

  2. In the Simulink Editor, in the Modeling tab, select Model Settings.

  3. On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.

  4. Under Coverage metrics, select Condition Decision as the structural coverage level.

  5. Click OK to close the Configuration Parameters dialog box and save your changes.

  6. Simulate the model by clicking Run. Review the results.

Introduced in R2006b