Main Content

Obtain Cumulative Coverage for Reusable Subsystems and Stateflow® Constructs

This example shows how to create and view cumulative coverage results for a model with a reusable subsystem.

Simulink® Coverage™ provides cumulative coverage for multiple instances of identically configured:

  • Reusable subsystems

  • Stateflow™ constructs

To obtain cumulative coverage, you add the individual coverage results at the command line. You can get cumulative coverage results for multiple instances across models and test harnesses by adding the individual coverage results.

Open example model

At the MATLAB® command line, type:

model ='slvnvdemo_cv_mutual_exclusion'; open_system(model);

This model has two instances of a reusable subsystem. The instances are named Subsystem 1 and Subsystem 2.

Get decision coverage for Subsystem 1

Execute the commands for Subsystem 1 decision coverage:

testobj1 = cvt([模型'/Subsystem 1']); testobj1.settings.decision = 1; covobj1 = cvsim(testobj1);

Get decision coverage for Subsystem 2

Execute the commands for Subsystem 2 decision coverage:

testobj2 = cvtest([model'/Subsystem 2']); testobj2.settings.decision = 1; covobj2 = cvsim(testobj2);

Add coverage results for Subsystem 1 and Subsystem 2

Execute the command to create cumulative decision coverage for Subsystem 1 and Subsystem 2:

covobj3 = covobj1 + covobj2;

Generate coverage report for Subsystem 1

Create an HTML report for Subsystem 1 decision coverage:

cvhtml('subsystem1',covobj1)

The report indicates that decision coverage is 50% for Subsystem 1. Thetruecondition forenable logical valueis not analyzed.

Generate coverage report for Subsystem 2

Create an HTML report for Subsystem 2 decision coverage:

cvhtml(“subsystem2”covobj2)

The report indicates that decision coverage is 50% for Subsystem 2. Thefalsecondition forenable logical valueis not analyzed.

Generate coverage report for cumulative coverage of Subsystem 1 and Subsystem 2

Create an HTML report for cumulative decision coverage for Subsystem 1 and Subsystem 2:

cvhtml('cum_subsystem',covobj3)

Cumulative decision coverage for reusable subsystems Subsystem 1 and Subsystem 2 is 100%. Both thetrueandfalseconditions forenable logical valueare analyzed.