Using Simulink    

Model Coverage Commands

cvhtml

Produce an HTML report of cvdata objects.

Create an HTML report of the coverage results in the cvdata object data. The report is written to file.

Create a combined report of several data objects. The results from each object are displayed in a separate column. Each data object must correspond to the same root subsystem, or the function produces errors.

Specify the detail level of the report with the value of detail, an integer between 0 and 3. Greater numbers indicate greater detail. The default value is 2.

cvload

Load coverage tests and results from file.

Load the tests and data stored in the text file FILENAME.CVT. The tests that are successfully loaded are returned in TESTS, a cell array of cvtest objects. DATA is a cell array of cvdata objects that were successfully loaded. DATA has the same size as TESTS but can contain empty elements if a particular test has no results.

If RESTORETOTAL is 1, the cumulative results from prior runs are restored. If RESTORETOTAL is unspecified or zero, the model's cumulative results are cleared.

Special considerations:

cvsave

Save coverage tests and results to file.

Save all the tests and results related to model in the text file filename.cvt.

Save the specified tests in the text file filename.cvt. Information about the referenced models is also saved.

Save the specified data objects, the tests that created them, and the referenced models' structure in the text file filename.cvt.

cvsim

Run a test case.

This command can take the following forms.

Execute the cvtest object test by starting a simulation run for the corresponding model. The results are returned in a cvdata object.

Returns the simulation time vector, t, state values, x, and output values, y.

Override the default simulation values. For more information, see the documentation for the sim command.

Execute a set of tests and return the results in cvdata objects.

Create and execute a cvtest object.

cvtest

Creates a test specification as required by cvsim. This command has the following syntax:

Create a test specification for the Simulink model containing root. root can be the name of the Simulink model or the handle to a Simulink model. root can also be a name or handle to a subsystem within the model, in which case only this subsystem and its descendents are instrumented for analysis.

Creates a test with the given label. The label is used when reporting results.

Creates a test with a setup command that is executed in the base MATLAB workspace just prior to running the instrumented simulation. The setup command is useful for loading data just prior to a test.

The cvtest object returned has the following structure:

Field
Description
id, modelcov(read-only)
Internal data-dictionary IDs
rootPath

Name of the system or subsystem instrumented for analysis

          label       
String used when reporting results
setupCmd

Command executed in the base workspace just prior to simulation.

settings

decision

          Set to 1 if decision coverage desired

condition 

Set to 1 if condition coverage desired

mcdc      

Set to 1 if MC/DC coverage desired

tableExec 

Set to 1 if look-up table coverage desired

Coverage Script Example

The following example demonstrates some of the common model coverage commands:

In this example we create two cvtest objects and then simulate according to these specifications. Each cvtest object uses the setupCmd property to load a data file prior to simulation. Decision coverage is enabled by default, and we have chosen to enable MC/DC coverage as well. After simulation we use cvhtml to display the coverage results for our two tests and the cumulative coverage. Lastly, we compute cumulative coverage with the + operator and save the results. For more detailed examples of how to use the model coverage commands see simcovdemo.m and simcovdemo2.m in the coverage root folder.


 HTML Settings