Collect Coverage for Code - MATLAB & Simulink (original) (raw)
Measure coverage for code in model elements or generated from models
Simulink® Coverage™ measures code coverage and indicates the untested elements of your design. You can collect coverage for the C/C++ code in supported model elements, MATLAB® Function blocks, or the code generated from models in software-in-the-loop (SIL) mode or processor-in-the-loop (PIL) mode. Simulink Coverage measures several types of code coverage analysis, such as statement, condition, decision, and modified condition/decision coverage.
Functions
slcovmex | Build coverage-compatible MEX-function from C/C++ code |
---|---|
cvtest | Create model coverage test specification object |
cvsim | Simulate and return model coverage results for test objects |
Model Settings
Set Scope of Coverage Analysis
Enable coverage analysis | Analyze coverage |
---|---|
Scope of coverage analysis | Set scope of coverage analysis |
Select Models | Select models to include in coverage analysis |
Select Subsystem | Select subsystem to include in coverage analysis |
Include in analysis: MATLAB files | Enable coverage for external MATLAB files |
Include in analysis: C/C++ S-functions | Analyze coverage for C/C++ S-Function blocks |
Structural coverage level | Types of coverage to analyze |
Set Coverage Recording Interval
Restrict coverage recording interval | Analyze coverage during a specific time interval |
---|---|
Coverage interval start time | Simulation time to begin coverage analysis |
Coverage interval stop time | Simulation time to stop coverage analysis |
Topics
Code Coverage Basics
- Types of Code Coverage
Perform several types of code coverage analysis for the code within supported Simulink elements or for code generated from models in SIL mode or PIL mode. - Specify Code Coverage Options
Set options for code coverage.
Coverage for MATLAB Code Used in Simulink
- Model Coverage for MATLAB Functions
Use model coverage for MATLAB Function blocks and interpret the results. - Coverage for MATLAB Function Blocks
This example explains how Model Coverage relates to MATLAB® code inside a MATLAB Function Block.
Coverage for Integrated C/C++ Code
- Coverage for Models with Code Blocks and Simulink Blocks
Record coverage for models with a combination of code blocks and other Simulink blocks. - Coverage for Custom C/C++ Code in Simulink Models
Analyze model coverage for C/C++ S-Functions. - View Coverage Results for Custom C/C++ Code in S-Function Blocks
View coverage results for the C/C++ code in S-Function blocks in your model.
Coverage for Generated Code
- Code Coverage for Models in Software-in-the-Loop (SIL) Mode and Processor-in-the-Loop (PIL) Mode
Configure code coverage for SIL and PIL simulations and review results. - View and Filter Code Coverage Results Using the Code Pane
This example shows how to view code coverage results and justify code coverage outcomes directly from the Code pane in Simulink®. - Evaluate Differences Between Model and Code Coverage
This example shows how to use Simulink® Test™ Manager to analyze model coverage and generated code coverage, and investigate differences in the results.
Featured Examples
Software-in-the-Loop Code Coverage
Collect code coverage metrics from a model reference using software-in-the-loop (SIL) mode.
Collect Code Coverage Metrics with Simulink Coverage
Collect code coverage metrics.
Use Justification Rules to Filter Code Coverage Outcomes
Filter code coverage outcomes in the coverage report after collecting coverage for a model in software-in-the-loop (SIL) or processor-in-the-loop (PIL) mode.
Coverage for S-Functions
Configure an S-Function generated with the Legacy Code Tool to be compatible with coverage. The model coverage tool supports S-Functions that are: