Debug Enhanced Modified Condition Decision Coverage Using Model Slicer
This example shows how to find the Simulink® Design Verifier™ generated objectives related to a specific model object using Model Slicer. Once the objectives are identified, Model Slicer highlights the slice at the step when the objective is observable.
This example uses the following products to demonstrate debugging enhanced Modified Condition Decision Coverage (MCDC):
Simulink Design Verifier
Enhanced MCDC analyzes the detectability of each objective in the model and generates non-masking test cases for each objective. It coordinates the effect of downstream blocks to avoid masking effects. It also calculates detection sites for each detectable objective where the effect of the objective can be observed. This data is available in the
sldvdemo_cruise_control_sldvdata.mat file generated by the analysis. These detection sites can be added to the equivalence criteria of back-to-back testing.
This example uses the following slicer configuration:
Starting point is set as the model object to be observed.
Exclusion point is set as the detection point relevant to the objective generated by Simulink Design Verifier.
Signal propagation is set to downstream (forward slice).
Step 1: Prepare the Model
1. Open the model.
model = 'sldvdemo_cruise_control'; open_system(model);
2. Load the data file generated by Simulink Design Verifier (sldvData) for test generation using Enhanced MCDC.
3. Choose the model object for which the objective must be highlighted and find its SID.
modelObjIdentifier = 'sldvdemo_cruise_control/Controller/Switch3'; modelobjSID = Simulink.ID.getSID(modelObjIdentifier);
Step 2: Setting Up Model Slicer
1. Enable FastRestart for the model.
Enabling FastRestart will simulate the model and collect the simulation data at various time stamps. This will allow us to use Step Back and Step Forward options.
2. Create and activate Model Slicer object.
slicerObject = slslicer(model); activate(slicerObject);
3. Set the signal propogation to downstream.
slicerObject.Configuration.SignalPropagation = 'downstream';
Step 3: Find Objectives Related to the Model Object
1. Access sldvData with an object of SldvDataExplorer class.
sldvObj = SldvDataExplorer(sldvData);
Note: The class SldvDataExplorer is a helper class. You can edit it as per your requirements.
2. Find all objectives related to the model object and the details of the objectives.
[objectives, tableOfObjectives] = sldvObj.getObjectivesForModelObj(modelobjSID); disp(tableOfObjectives);
ObjectiveNum Type Description Detectability Status TestCaseId ____________ __________ _____________________________________________________________ _____________ ___________ __________ 1 "Decision" "logical trigger input false (output is from 3rd input port)" "Detectable" "Satisfied" 1 2 "Decision" "logical trigger input true (output is from 1st input port)" "Detectable" "Satisfied" 1
The follwing details of the objectives are saved in
ObjectiveNum - Objective number.
Type - MCDC/Decision/Condition.
Description - Description of the objective as generated by Simulink Design Verifier.
Detectability - The detectability status of an objective.
Status - The status of an objective.
TestCaseId - Integer that represents the index of a test case or counterexample that addresses an objective.
Step 4: Highlighting the Objectives
For this example, we will highlight the first objective from the table.
1. Obtain the simulation input object with the input values set according to the test case that corresponds to the objective.
[simIn, atStep, ~] = sldvObj.getSimInObjForObjective(objectives(1));
2. Allow rollback in the model so it is possible to step backwards in the model and set the number of simulation rollback steps to 1.
simIn = simIn.setModelParameter('EnableRollBack','on'); simIn = simIn.setModelParameter('NumberOfSteps', 1);
3. Apply Simulink input object to model.
4. Find all the detection sites for the selected objective.
objectDetectionSites = sldvObj.getObjectDetectionSites(objectives(1));
5. Add all detection sites as exclusion points.
for n = 1:length(objectDetectionSites) detectionSite = objectDetectionSites(n).modelObj; slicerObject.addExclusionPoint(detectionSite); end
6. Add the model object as an starting point.
7. Step to the point in the testcase where the objective is observable.
for q = 1:atStep slicerObject.stepForward(); end
Now you can observe that the slice is highlighted.
Perform the following actions to cleanup the model:
1. Clear the slicer object.
2. Clear the Simulink input object.
clear slicerObject simIn
3. Reset the FastRestart parameter of the model.