For a software-in-the-loop (SIL) or processor-in-the-loop (PIL) simulation, you can configure third-party code coverage analysis by using command-line APIs.
For BullseyeCoverage, you can use this workflow:
Using get_param
, retrieve the
object containing coverage settings for the current model. For
example:
covSettings = get_param(gcs, 'CodeCoverageSettings')
covSettings = CodeCoverageSettings with properties: TopModelCoverage: 'off' ReferencedModelCoverage: 'off' CoverageTool: 'None'
The property TopModelCoverage
determines whether
the software generates code coverage data for just the top model, while
ReferencedModelCoverage
determines whether the
software generates coverage data for models referenced by the top model.
If neither property is 'on'
, the code generator does
not produce code coverage data during a SIL or PIL simulation.
When you save your model, the properties
TopModelCoverage
,
ReferencedModelCoverage
, and
CoverageTool
are also saved.
Check the class of
covSettings
.
class(covSettings)
ans = 'coder.coverage.CodeCoverageSettings'
Turn on BullseyeCoverage code coverage analysis for the top model and referenced models.
covSettings.TopModelCoverage='on'; covSettings.ReferencedModelCoverage='on'; covSettings.CoverageTool='BullseyeCoverage';
CoverageTool
to
'LDRA Testbed'
.Using set_param
, apply the
new coverage settings to the model.
set_param(gcs,'CodeCoverageSettings', covSettings);
Assuming the third-party code coverage tool is installed, specify the installation path.
coder.coverage.BullseyeCoverage.setPath('C:\Program Files\BullseyeCoverage')
For LDRA Testbed, use
coder.coverage.LDRA.setPath('C:\...)
.
Check that the path is saved as a preference.
coder.coverage.BullseyeCoverage.getPath
For LDRA Testbed, use
coder.coverage.LDRA.getPath
.
If your model uses a configuration set that is not attached to the model, for example, a configuration reference, then the Configure button is dimmed in the Configuration Parameters dialog box. You cannot open the Code Coverage Settings dialog box and you must use line commands to specify code coverage settings.
To configure third-party code coverage analysis for a model that uses a configuration reference:
Get the active configuration set from the model.
cs = getActiveConfigSet(gcs)
Retrieve the current code coverage settings.
covSettings = get_param(cs, 'CodeCoverageSettings')
Specify the code coverage settings that you require. For example:
covSettings.TopModelCoverage = 'on'; covSettings.ReferencedModelCoverage='on'; covSettings.CoverageTool='BullseyeCoverage';
Get the configuration set that is specified by the configuration reference.
csBase = cs.getRefConfigSet
Apply the required code coverage settings to the referenced configuration set.
set_param(csBase, 'CodeCoverageSettings', covSettings);