Specify Code Coverage Options - MATLAB & Simulink (original) (raw)

Main Content

Simulink® Coverage™ provides three modes of code coverage analysis.

For general coverage options, see Specify Coverage Options.

Models with Custom C/C++ Code Blocks

You can collect code coverage for custom code blocks in your model, such asS-Functions and C Caller blocks. Simulink Coverage reports custom C/C++ code blocks in a code coverage report, even if you run your model in normal simulation mode.

You need to configure an S-Function block for coverage. For more information, see Coverage for Custom C/C++ Code in Simulink Models.

Models with Software-in-the-Loop and Processor-in-the-Loop Mode Blocks

You can collect code coverage for a model or model reference when you set theSimulation mode parameter to Software in the Loop (SIL). There are a few configuration parameters that you must set to allow coverage analysis of the generated code from your model:

  1. In the Modeling tab, click Model Settings to open the Configuration Parameters dialog box.
  2. In the pane set theSystem target file in the section toert.tlc.
  3. In the left pane, expand the Code Generation node. Select Verification.
  4. In the Code coverage for SIL or PIL section, setThird-party tool to:
    • None (use Simulink Coverage)
    • BullseyeCoverage
    • LDRAcover or LDRA tool suite

BullseyeCoverage and the LDRA tool suite are third-party tools supported by Embedded Coder®. For more information about third-party code coverage tool support, see Code Coverage Tool Support (Embedded Coder). To set code coverage options, click Configure. If you setThird-party tool to None (use Simulink Coverage), then clicking Configure opens the pane.

Using Simulink Coverage for code coverage means that you can analyze coverage results, justify missing coverage, and generate test cases from within the Simulink environment.

Models with MATLAB Function Blocks

When you record coverage for models containing MATLAB® Function blocks, the model coverage report includes the MATLAB code inside a MATLAB function block, but a separate code coverage report reports the external MATLAB files called by the MATLAB Function block.

To include MATLABFunction blocks in your analysis:

  1. In the Simulink Editor, select Model Settings on theModeling tab.
  2. In the Configuration Parameters dialog box, clickCoverage. Under Include in analysis, select .

See Also

Topics