debug enhanced modified condition decision coverage using model slicer -凯发k8网页登录
this example shows how to find the simulink® design verifier™ generated objectives related to a specific model object using . 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
model slicer
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.
load('sldvdemo_cruise_control_sldvdata.mat');
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.
set_param(model,'fastrestart','on');
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 tableofobjectives
table:
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.
slicerobject.applysimintomodel(simin);
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.
slicerobject.addstartingpoint(modelobjsid);
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.
cleanup
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.
set_param(model,'fastrestart','off');