decisioninfo - Retrieve decision coverage information from cvdata

        object - MATLAB ([original](https://in.mathworks.com/help/slcoverage/ref/decisioninfo.html)) ([raw](?raw))

Retrieve decision coverage information from cvdata object

Syntax

Description

[covInfo](#brxo3wo-1-coverage) = decisioninfo([cvdo](#brxo3wo-1%5Fsep%5Fbrxo2jj-1-cvdo), [modelObject](#brxo3wo-1%5Fsep%5Fbswieqq-1-object)) returns decision coverage results from the cvdata objectcvdo for the model component specified bymodelObject.

[covInfo](#brxo3wo-1-coverage) = decisioninfo([cvdo](#brxo3wo-1%5Fsep%5Fbrxo2jj-1-cvdo), [modelObject](#brxo3wo-1%5Fsep%5Fbswieqq-1-object), [simMode](#brxo3wo-1%5Fsep%5Fbswieqq-1-mode)) returns decision coverage results from the cvdata objectcvdo for the model component specified bymodelObject for the simulation modesimMode.

[covInfo](#brxo3wo-1-coverage) = decisioninfo([cvdo](#brxo3wo-1%5Fsep%5Fbrxo2jj-1-cvdo), [modelObject](#brxo3wo-1%5Fsep%5Fbswieqq-1-object), [ignoreDescendants](#brxo3wo-1%5Fsep%5Fmw%5Ffeb2a172-08b8-4e3b-b2bb-6c8d51d75f21)) returns decision coverage results for modelObject, depending on the value of ignoreDescendants.

[[covInfo](#brxo3wo-1-coverage), [description](#brxo3wo-1-description)] = decisioninfo([cvdo](#brxo3wo-1%5Fsep%5Fbrxo2jj-1-cvdo), [modelObject](#brxo3wo-1%5Fsep%5Fbswieqq-1-object)) returns decision coverage results and text descriptions of decision points associated with modelObject.

Examples

collapse all

This example shows how to view decision coverage data 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 = setModelParameter(simIn,'CovEnable','on'); simIn = setModelParameter(simIn,'CovMetricStructuralLevel','Decision'); simIn = setModelParameter(simIn,'CovSaveSingleToWorkspaceVar','on'); simIn = setModelParameter(simIn,'CovSaveName','covData');

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

Extract the coverage data as a cvdata object from the SimulationOutput object, simOut.

covData = simOut.covData;

View the decision coverage results for the Saturation block by calling decisioninfo with the block path.

blockPath = [modelName,'/Saturation']; decisionCov = decisioninfo(covData,blockPath)

decisioninfo returns an array with two scalars. The first value is the number of satisfied decision outcomes, and the second value is the number of total decision outcomes. Use these to determine the percentage of satisfied decision outcomes for the Saturation block.

percentDecisionCov = 100 * decisionCov(1) / decisionCov(2)

  1. Open the example and load the model.
    openExample("slcoverage/RetrieveCodeCoverageResultsExample");

  2. Use the setupSILCoverage function to configure the model for code coverage analysis. The output is aSimulink.SimulationInput object.
    simIn = setupSILCoverage("slvnvdemo_counter_harness");

  3. Simulate the model.

  4. To retrieve coverage results for the generated code that represents a specific block, use the block path. For example, retrieve the decision coverage results for the Switch block named limit by passing the block path relative to the top model.
    covDataSIL = simOut.covdata;
    decBlockSIL = decisioninfo(covDataSIL,...
    "slvnvdemo_counter/ limit")

  5. 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 decision coverage results for the functionslvnvdemo_counter located in the source fileslvnvdemo_counter.c.
    decSILFunction = decisioninfo(covDataSIL,{"slvnvdemo_counter.c",...
    "slvnvdemo_counter"})

  6. Open the example and load data into the workspace.
    openExample("slcoverage/RetrieveSFunCoverageResultsExample");
    load slcoverage_lct_data.mat

  7. Use the setupSFcnCoverage function to configure the model for coverage analysis. The output is aSimulink.SimulationInput object.
    simIn = setupSFcnCoverage("slcoverage_lct_bus");

  8. Simulate the model.

  9. To retrieve coverage results for an S-function, use thedecisioninfo 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 decision coverage results for the function named counterbusFcn in the S-function file counterbus.c, which theS-Function blockslcoverage_sfun_counterbus calls. The S-Function block is inside the TestCounter subsystem in the modelslcoverage_lct_bus.
    covDataSFcn = simOut.covdata;
    decSFun = decisioninfo(covDataSFcn,...
    {"slcoverage_lct_bus/TestCounter/slcoverage_sfun_counterbus",...
    "counterbus.c","counterbusFcn"})

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

Simulation mode during coverage analysis, specified as one of these options:

Object Specification Description
"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 SIL or PIL simulation mode.
"ModelRefTopSIL" or "ModelRefTopPIL" 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 logical1 (true) or 0 (false), where:

Data Types: single | double | logical

Output Arguments

collapse all

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.

covered_outcomes Number of decision outcomes satisfied formodelObject
total_outcomes Total number of decision outcomes formodelObject

Data Types: double

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

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

Information for individual decisions, returned as a structure with the following fields:

Decision exclusion flag, returned as1 if the decision is excluded or 0 if it is not.

Data Types: double

Decision justification flag, returned as1 if the decision 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 decision, returned as a character array.

Data Types: char

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

text Outcome of the decision, returned as'true' or'false'.
executionCount The number of time steps the decision had this outcome, returned as a scalar double.
isFiltered Decision outcome exclusion flag, returned as 1 if the outcome is excluded or 0 if it is not.
isJustified Decision outcome justification flag, returned as 1 if the outcome is justified or 0 if it is not.
filterRationale Coverage filter rationale, returned as a character array.
executedIn Aggregated coverage test case traceability information, returned as a structure array. If your coverage data does not contain aggregated results from multiple simulations,executedIn is an empty array. If your coverage data contains aggregated results,executedIn indicates which test runs executed the decision outcome.
executedIn.uniqueId Unique identifier for thecvdata object created by the test case that executed this condition outcome, returned as a character array.
executedIn.analyzedModel The name of the model analyzed, returned as a character array.
executedIn.description The test case description, returned as a character array.
executedIn.date The date and time of the simulation that created the cvdata object, returned as a character array.
executedIn.traceLabel The short name of the test case, returned as a character array.
executedIn.testRunInfo Test details, returned as a structure array.
executedIn.testRunInfo.runid The identifier of the run that generated the coverage result, returned as a scalar double.
executedIn.testRunInfo.runName The name of the test case that generated the coverage result, returned as a character array.
executedIn.testRunInfo.testId Identifying data for the test case that generated the coverage result, returned as a structure array.
executedIn.testRunInfo.testId.uuid The unique identifier for the test case that generated the coverage result, returned as a character array.
executedIn.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 Test Manager in Simulink Testâ„¢

Data Types: struct

Data Types: struct

Data Types: struct

Alternatives

Use the coverage settings to collect and display decision coverage results:

  1. Open the model.
  2. In the Model Editor, select Model Settings on theModeling tab.
  3. On the Coverage pane of the Configuration Parameters dialog box, select Enable coverage analysis.
  4. Under Coverage metrics, selectDecision 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 the Run button and review the results.

Version History

Introduced in R2006b