Main Content

cvtest

Create model coverage test specification object

Description

Use cvtest to create a test specification object that stores model coverage settings. Pass the cvtest object to the cvsim function to execute coverage analysis based on your settings.

Creation

Description

example

cvto = cvtest(root) creates a cvtest object with default coverage settings. root can be the name of a model or the handle to a model. root can also be the name or handle to a subsystem within the model, in which case only the specified subsystem and its descendents are analyzed for coverage.

cvto = cvtest(root,label) creates a cvtest object with the designated label.

cvto = cvtest(root,label,setupCmd) creates a cvtest object with the setup command setupCmd. The setup command is executed in the base MATLAB® workspace before running coverage analysis.

Note

Coverage metric settings specified in the cvtest object override coverage metric settings set in the model configuration parameters.

Input Arguments

expand all

Model name or handle, or path to a subsystem, specified as a character array or string array.

Properties

expand all

This property is read-only.

Internal model ID, returned as a scalar.

This property is read-only.

Internal coverage configuration ID, returned as a scalar.

This property is read-only.

Name of the system you specified to analyze, returned as a character array or string array.

Data Types: char | string

Test label, specified as a character array or a string array. This label appears in the coverage report as the test name.

Data Types: char | string

Command executed in base MATLAB workspace before simulation, specified as a character array or string array.

The setup command is executed before each simulation.

Data Types: char | string

Types of coverage to collect, specified as a structure.

settings includes the following fields:

Property

Description

Values

settings.decision

Enable decision coverage data.

1 (default) | 0

settings.condition

Enable condition coverage data.

1 | 0 (default)

settings.mcdc

Enable modified condition decision coverage (MCDC) data.

If settings.mcdc is enabled, you can also choose which definition of MCDC to use with the options.mcdcmode property.

1 | 0 (default)

settings.designverifier

Enable coverage data from Simulink® Design Verifier™ blocks.

1 | 0 (default)

settings.tableExec

Enable coverage data for lookup tables.

1 | 0 (default)

settings.sigrange

Enable signal range data.

1 | 0 (default)

settings.sigsize

Enable signal size data.

1 | 0 (default)

settings.overflowsaturation

Enable saturation on integer overflow coverage data.

1 | 0 (default)

settings.relationalop

Enable relational boundary coverage data.

Use options.covBoundaryRelTol and options.covBoundaryAbsTol to specify tolerances for this type of coverage.

For more information, see Relational Boundary Coverage

1 | 0 (default)

Advanced coverage options, specified as a structure.

options includes the following fields:

Property

Description

Values

options.covBoundaryRelTol

Relative tolerance for relational boundary coverage.

For more information, see Relational Boundary Coverage.

0.01 (default) | scalar

options.CovBoundaryAbsTol

Absolute tolerance for relational boundary coverage.

For more information, see Relational Boundary Coverage.

1e-5 (default) | scalar

options.useTimeInterval

Whether to restrict model coverage recording to a specified simulation time interval.

Use options.intervalStartTime and options.intervalStopTime to specify the time interval.

For more information, see Specify Coverage Options

1 | 0 (default)

options.intervalStartTime

When to start recording coverage.

Specify this property if options.useTimeInterval is enabled.

0 (default) | scalar

options.intervalStopTime

When to stop recording coverage.

Specify this property if options.useTimeInterval is enabled.

0 (default) | scalar

options.forceBlockReduction

Whether to record coverage for blocks flagged with the Block Reduction parameter.

  • 1 (default) — Override the Simulink Block Reduction parameter if it is enabled. Coverage is recorded for every supported block in the model. The value of the configuration parameter Block Reduction is ignored.

  • 0 — Use the value for the configuration parameter Block Reduction. If Block Reduction is enabled, coverage is not recorded for blocks that are effectively removed from the model because of block reduction. For instance, coverage is not recorded for a block that is reduced by dead code elimination.

For more information, see Block reduction

1 (default) | 0

options.mcdcMode

Which MCDC definition to apply to the model, specified as one of the following options:

  • 'masking' — Use the masking definition of MCDC coverage.

  • 'unique cause' — Use the unique cause definition of MCDC coverage.

For more information, see Modified Condition and Decision Coverage (MCDC) Definitions in Simulink Coverage.

'masking' (default) | 'unique cause'

Coverage filter, specified as a structure.

filter has one field, filter.fileName. filter.fileName is the name of a coverage filter file to apply to coverage analysis, specified as a character array or string array.

For more information, see Coverage Filter Rules and Files

Model reference settings, specified as a structure.

modelRefSettings includes the following fields:

Property

Description

Values

modelRefSettings.enable

Model reference coverage setting, specified as one of the following options:

  • 'off' — Disable coverage for referenced models.

  • 'all' or 'on' — Enable coverage for supported referenced models.

  • 'filtered' — Enable coverage for supported referenced models except those listed in the excludedModels field.

'off' (default) | 'on' | 'all' | 'filtered'

modelRefSettings.excludeTopModel

Whether to exclude the top model from coverage analysis, specified as a numeric or logical 1 (true) or 0 (false).

1 (default) | 0

modelRefSettings.excludedModels

Referenced models to exclude from coverage analysis, specified as a single character or string array of comma-separated model names.

To use this field, set modelRefSettings.enable to 'filtered'.

char | string

Whether to collect coverage for external program files called by MATLAB functions in your model, specified as a structure.

emlSettings has one field, emlSettings.enableExternal. Set emlSettings.enableExternal to 1 if you want to collect coverage for external program files called by MATLAB functions, and 0 if you do not want to collect coverage for external program files called by MATLAB functions.

Whether to collect coverage for C/C++ S-Function blocks in your model, specified as a structure.

sfcnSettings has one field, sfcnSettings.enableSfcn. Set sfcnSettings.enableSfcn to 1 if you want to collect coverage for S-Functions in your model, and 0 if you do not want to collect coverage for S-Functions in your model.

For more information, see S-Function.

Examples

collapse all

This example shows how to run coverage analysis using a cvtest object.

Open the slvnvdemo_ratelim_harness model and define the test object using cvtest. When you create the cvtest object, specify the Adjustable Rate Limiter block as the model object to analyze.

load_system('slvnvdemo_ratelim_harness');
testObj = cvtest(['slvnvdemo_ratelim_harness', ...
		  '/Adjustable Rate Limiter']);
testObj.label = 'Gain within slew limits';

Add a setup command to testObj. The setup command executes in the base MATLAB workspace before coverage analysis. In this case, the setup command loads data into the workspace that is required for the simulation.

testObj.setupCmd = ...
	'load within_lim.mat';

To collect decision coverage and saturation on integer overflow coverage, enable the decision and overflowsaturation properties in testObj object by setting the properties to true or 1.

testObj.settings.decision = true;
testObj.settings.overflowsaturation = true;

Finally, perform the coverage analysis by calling cvsim with testObj.

cvdo = cvsim(testObj);

Version History

Introduced before R2006a