cvsave - Save coverage settings and results to file - MATLAB (original) (raw)
Save coverage settings and results to file
Syntax
Description
cvsave([fileName](#mw%5F4d1172aa-f217-42e6-bcef-1f0c315d572a),[model](#mw%5Fddf68dc9-e850-476d-9784-3f07e5c56512))
saves the coverage settings and results related to model
in the filefileName
.
cvsave([fileName](#mw%5F4d1172aa-f217-42e6-bcef-1f0c315d572a),[covData](#mw%5F04c13ef0-30b5-4101-b2ff-f4ff6293f43a))
saves the coverage settings and results contained in the cvdata
object covData
.
cvsave([fileName](#mw%5F4d1172aa-f217-42e6-bcef-1f0c315d572a),[covSettings](#mw%5F25238a3c-3cf5-44d1-9efe-c95d54932f86)1,...,[covSettings](#mw%5F25238a3c-3cf5-44d1-9efe-c95d54932f86)N)
saves multiple cvtest
objects and information about any referenced models.
Examples
This example shows how to save coverage data to a file.
Start by loading the model into memory.
modelName = 'slvnvdemo_cv_small_controller'; load_system(modelName);
Simulate the model with the coverage settings that are saved with the model.
covData = cvsim(modelName);
Save a coverage data file called coverage_data
, containing the coverage data in the cvdata
object covData
.
cvsave('coverage_data',covData);
This example shows how to save more than one coverage data object to a single coverage data file.
Load the Model
Load the model into memory.
modelName = 'slvnvdemo_ratelim_harness'; load_system(modelName);
Set Model Parameters for Coverage
Create a Simulink.SimulationInput
object to set coverage parameters.
covSet = Simulink.SimulationInput(modelName); covSet = covSet.setModelParameter('CovEnable','on'); covSet = covSet.setModelParameter('CovMetricStructuralLevel','MCDC'); covSet = covSet.setModelParameter('CovScope','Subsystem'); covSet = covSet.setModelParameter('CovPath','/Adjustable Rate Limiter'); covSet = covSet.setModelParameter('CovSaveSingleToWorkspaceVar','on');
Simulate the Model to Collect Coverage Data
Load the data files and then simulate the model to collect two sets of coverage data.
load within_lim.mat covSet = covSet.setModelParameter('CovSaveName','covData1'); simOut1 = sim(covSet);
Simulate the model a second time using the second data file.
load rising_gain.mat covSet = covSet.setModelParameter('CovSaveName','covData2'); simOut2 = sim(covSet);
Save the Coverage Data to a File
Save the results in a cell array.
cov_results{1} = covData1; cov_results{2} = covData2
cov_results =
1×2 cell array
{1×1 cvdata} {1×1 cvdata}
Save the results to a file.
cvsave('ratelim_testdata',cov_results{:});
Input Arguments
Name of coverage data file, specified as a character array or a string array. cvsave
appends the extension.cvt
to the name of the file when saving it.
Example: 'myCoverageDataFile'
Data Types: char
| string
Simulink model that has coverage data, specified as a character array or a string array. model
can be the name of a model or a handle to a model.
Example: 'mySimulinkModel'
Data Types: char
| string
Coverage settings, specified as a cvtest
object, or a cell array of cvtest
objects.
Data Types: cvtest
| cell
Coverage data, specified as a cvdata
object or a cell array of cvdata
objects.
Data Types: cvdata
| cell
Alternatives
You can save coverage results to a MATLAB workspace variable when you run your model in Simulink:
- Open the model for which you want to save cumulative coverage results.
- On the Modeling tab, select Model Settings.
- In the left pane of the Configuration Parameters dialog box, selectCoverage.
- Select Enable coverage analysis.
- In the Results section, select Save last run in workspace variable.
- Click OK to close the Configuration Parameters dialog box and save your changes.
- Simulate the model by clicking the Run button and review the results.
Version History
Introduced before R2006a