Main Content

slcoverage.Filter class

Package: slcoverage

Coverage filter set


Create a coverage filter object to add filter rules to.


filt = slcoverage.Filter() creates an slcoverage.Filter object.

filt = slcoverage.Filter(filterFile) adds the filter rules in filterFile to the filter.

Input Arguments

expand all

Filter file (.cvf file), specified as a character vector of the path name to the file. You do not need to include the extension.

Example: 'myfilt', 'filters/myfilt'


addRuleAdd coverage filtering rule to filter
removeRuleRemove rule from filter rule set
rulesRules for filter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.


collapse all

Create a filter object and add a rule to it. In this example, you add a rule to exclude some blocks from coverage testing.

Open the model. Specify coverage settings and turn on coverage recording.

modelName = 'sldemo_lct_bus';

Select blocks with block type 'RelationalOperator' to add a filter rule for.

bl = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockType,'RelationalOperator');

Create a filter object, create a rule, and add the rule to the filter.

filt = slcoverage.Filter;
rule = slcoverage.FilterRule(bl,'Tested elsewhere',slcoverage.FilterMode.Exclude);

After you create a filter and add one or more rules to it, save the filter to a file. Simulate the model for code coverage. Add the filter file as the value to the filter property of the resulting cvdata object.'blfilter');
csim = cvsim(modelName);
csim.filter = 'blfilter';

Examine the HTML report and notice the rules that were added for the blocks. The coverage report shows the excluded blocks and the rationale.

This example assumes that you have two existing filter files, myfilt1.cvf and myfilt2.cvf. Simulate the model for coverage. Add the filter files to the filter property of the resulting cvdata object.

csim = cvsim(modelName);
csim.filter = {'myfilt1', 'myfilt2'};

This example assumes that you have an existing filter file myfilt.cvf that you want to add a rule to. Create a filter object that uses that file. Add a rule to the filter object and then save the file again.

filt = slcoverage.Filter('myfilt');
bl = slcoverage.BlockSelector(slcoverage.BlockSelectorType.BlockInstance,'sldemo_lct_bus:23');

rule = slcoverage.FilterRule(bl,'Edge case');
Introduced in R2017b