How to use Simulink Design Verifier to test Variants?

3 views (last 30 days)
How to identify design errors and meet coverage for all the variant choices in a model?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Dec 2022
Edited: MathWorks Support Team on 21 Dec 2022
Simulink Design Verifier (SLDV) considers only the active variant choice to generate the test cases. With the variant model having many choices, a user can choose one of the below workflows to generate test cases for all required paths. Leveraging the Simulink Design Verifier to generate test cases for a model with Variant Subsystems requires extra steps.
Workflow 1: Toggling Variant choices
  • Open the model under test.
  • Activate specific variant choice(s). 
  • In the SLDV configuration option, set output file names specific to each choice, this will ensure each choice has a separate SLDV output file.
  • Perform SLDV run on the model (Design Error Detection, Test Generation).
  • Generate report and analyze results.
  • Toggle choices and re-run SLDV analysis. 
Workflow 2: Using Variants Manager
The user can generate test cases for defined configurations in the Variant Manager
  • Open the model under test.
  • Get defined variant configurations in the Variant Manager.
config = Simulink.VariantManager.getConfigurationData(modelName) 
  • Validate all configurations one by one in a loop using "Simulink.VariantManager.activateModel" API, this will activate one set of configurations at a time. This API is introduced in MATLAB R2022b.
 Note: If Variant Control parameters are defined in Data Dictionary, the Data Dictionary needs to be saved after activating a specific variant configuration.
Simulink.VariantManager.activateModel(modelName,Configuration = config.VariantConfigurations(i).Name);
  • Set SLDV output file names (this will help to differentiate between different reports associated with each configuration) 
opts = sldvoptions(modelName)
opts.DataFileName = [modelName '_' config.VariantConfigurations(i).Name '_sldvdata']; 
opts.ReportFileName =  ['SLDV_Report_' modelName '_' config.VariantConfigurations(i).Name]; 
set_param(modelName,'SimulationCommand','Update') 
[status,fileNames] = sldvrun(modelName,opts,true); 
Our demo example "slexVariantVnVWorkflow"
showcases a similar workflow to generate test cases for variant subsystems in the model using SLDV.

More Answers (0)

Categories

Find more on Variant Systems in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!