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:
get_param, retrieve the
object containing coverage settings for the current model. For
covSettings = get_param(gcs, 'CodeCoverageSettings')
covSettings = CodeCoverageSettings with properties: TopModelCoverage: 'off' ReferencedModelCoverage: 'off' CoverageTool: 'None'
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
CoverageTool are also saved.
Check the class of
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';
set_param, apply the
new coverage settings to the model.
Assuming the third-party code coverage tool is installed, specify the installation path.
For LDRA Testbed, use
Check that the path is saved as a preference.
For LDRA Testbed, use
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);