MATLAB: How to use Simulink Design Verifier to test Variants

configurationdesigndetectionerrorgenerationmanagersldvtestvariants

How to identify design errors and meet coverage for all the variant choices in a model?

Best Answer

Simulink Design Verifier 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 choices(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 Configurations Manager 
The user can generate test cases for defined configurations in the Variants Manager 
  • Open the model under test 
  • Get defined variant configurations in the variant’s configuration manager 
config = Simulink.VariantConfigurationData.getFor(modelName) 
  • Validate all configurations one by one in a loop, this will activate one set of configurations at a time: 
[valid, err] = Simulink.VariantConfigurationData.validateModel(modelName,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 ( https://www.mathworks.com/help/simulink/ug/variants-example-models.html ) showcases similar workflow to generate test cases for variant subsystems in the model using SLDV