Using Simulink | ![]() |
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.
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
Note You do not have to enable model coverage reporting (see Creating and Running Test Cases) to use this command. |
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:
Coverage Script Example
The following example demonstrates some of the common model coverage commands:
testObj1 = cvtest('ratelim_harness/Adjustable Rate Limiter'); testObj1.label = 'Gain within slew limits'; testObj1.setupCmd = 'load(''within_lim.mat'');'; testObj1.settings.mcdc = 1; testObj2 = cvtest('ratelim_harness/Adjustable Rate Limiter'); testObj2.label = 'Rising gain that temporarily exceeds slew limit'; testObj2.setupCmd = 'load(''rising_gain.mat'');'; testObj2.settings.mcdc = 1; [dataObj1,T,X,Y] = cvsim(testObj1,[0 2]); [dataObj2,T,X,Y] = cvsim(testObj2,[0 2]); cvhtml('ratelim_report',dataObj1,dataObj2); cumulative = dataObj1+dataObj2; cvsave('ratelim_testdata',cumulative);
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 |