slcoverage.Filter Class
Namespace: slcoverage
Coverage filter set
Description
Use an object of the slcoverage.Filter
class to filter out unsatisfied
coverage objectives by creating rules using the slcoverage.FilterRule
class.
The slcoverage.Filter
class is a handle
class.
Creation
Description
creates
an filt
= slcoverage.Filter()slcoverage.Filter
object.
creates an filt
= slcoverage.Filter(filterFile
)slcoverage.Filter
object that contains the filter
rules saved in filterFile
.
Input Arguments
filterFile
— Filter file
path name
Filter file in CVF format, specified as a character array of the path name to the file, or a cell array of character arrays. You do not need to include the file extension.
Example: 'myfilt'
,
'filters\myfilt'
, {'myfilt1',
'myfilt2'}
Methods
Public Methods
addRule | Add coverage filtering rule to filter |
removeRule | Remove rule from filter rule set |
rules | Rules for filter |
setFilterName | Set name of coverage filter object |
filterName | Get name of coverage filter object |
setFilterDescription | Set description of coverage filter object |
filterDescription | Get description of coverage filter object |
save | Save coverage filter object to coverage filter file |
Examples
Add Rule to a Filter File
This example shows how to add a rule to a coverage filter file.
Create a filter object and use the BlockSelector
class to create a BlockSelector
object for the Saturation block in the slvnvdemo_covfilt
model.
filt = slcoverage.Filter; blockSel = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,... 'slvnvdemo_covfilt/Saturation');
Create a rule to filter the Saturation block using slcoverage.FilterRule
with the selector as the first input and the rationale as the second input.
rule = slcoverage.FilterRule(blockSel,'Edge case');
Use the addRule
method of the slcoverage.Filter
class to add the rule to the filter object.
addRule(filt,rule);
Save the filter with the new rule to a filter file using the save
method of the slcoverage.Filter
class.
save(filt,'myFilterFile')
Create and Use a Coverage Filter Object
This example shows how to create a filter object and add a rule to exclude a subsystem from coverage analysis.
Open the slvnvdemo_covfilt
model. Use a SimulationInput
object to enable coverage recording and specify coverage settings.
modelName = 'slvnvdemo_covfilt'; load_system(modelName) simIn = Simulink.SimulationInput(modelName); simIn = setModelParameter(simIn,'CovEnable','on'); simIn = setModelParameter(simIn,'CovMetricStructuralLevel','MCDC'); simIn = setModelParameter(simIn,'CovSaveSingleToWorkspaceVar','on'); simIn = setModelParameter(simIn,'CovSaveName','covData');
Simulate the model. The coverage data is stored in the value supplied for the CovSaveName
property.
simOut = sim(simIn); covData = simOut.covData;
You can filter a block by using the slcoverage.BlockSelector
class. To exclude the Switchable config subsystem, use slcoverage.BlockSelectorType.SubsystemAllContent
as the first input.
subsysSel = slcoverage.BlockSelector(... slcoverage.BlockSelectorType.SubsystemAllContent,... 'slvnvdemo_covfilt/Switchable config');
Create the filter rule by passing the selector, rationale, and the exclude filter mode as inputs.
rule = slcoverage.FilterRule(subsysSel,... 'Unused configuration',... slcoverage.FilterMode.Exclude);
Create an slcoverage.Filter
object and then add the rule to it.
filt = slcoverage.Filter; addRule(filt,rule);
Save the filter to a file called blockFilter.cvf
. To create a report that uses this coverage filter, add the filter file as the value to the filter
property of covData
, and create a report called coverageData.html
using covData
.
save(filt,'blockFilter') covData.filter = 'blockFilter'; cvhtml('coverageData',covData);
Use Multiple Coverage Filter Files for a Simulation
If you have multiple filter files that each contain their own set of rules, you can apply them to a coverage result set by creating a cell array of the filter file names or path names. In this example, you apply two filter files to a single cvdata
object and then view the report to see that the filters are applied.
Load the slvnvdemo_covfilt
model into memory.
modelName = 'slvnvdemo_covfilt';
load_system(modelName)
Set the coverage settings by using a Simulink.SimulationInput
object and simulate the model using sim
.
simIn = Simulink.SimulationInput(modelName); simIn = setModelParameter(simIn,'CovEnable','on'); simIn = setModelParameter(simIn,'CovMetricStructuralLevel','MCDC'); simIn = setModelParameter(simIn,'CovSaveSingleToWorkspaceVar','on'); simIn = setModelParameter(simIn,'CovSaveName','covData'); simOut = sim(simIn);
Apply the two filters to the cvdata
object by assigning them to the filter property as a cell array.
covData.filter = {'filter_1','filter_2'}; cvhtml('twoFiltersCovData',covData);
You can see the applied coverage filters in the Objects Filtered from Coverage Analysis section of the coverage report.
Version History
Introduced in R2017b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)