www.gusucode.com > slvnv 源码程序 matlab案例代码 > slvnv/ObtainCumulativeCoverageForReusableSubsystemsExample.m
%% Obtain Cumulative Coverage for Reusable Subsystems and Stateflow(R) Constructs % This example shows how to create and view cumulative coverage results % for a model with a reusable subsystem. % % Simulink(R) Verification and Validation(TM) provides cumulative coverage % for multiple instances of identically configured: % % * Reusable subsystems % * Stateflow(TM) 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(R) command line, type: % Copyright 2015 The MathWorks, Inc. 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 = cvtest([model '/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. The % |true| condition for |enable logical value| is 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. The % |false| condition for |enable logical value| is 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 the |true| and |false| conditions for |enable % logical value| are analyzed.