Этот пример показывает, как использовать генерацию тестов на модели с пользовательским кодом в диаграмме Stateflow.
open_system('sldvexSFCustomCodeExample');

Используйте функцию sldvrun, чтобы запустить анализ Simulink® Design Verifier™.
opts = sldvoptions; opts.Mode = 'TestGeneration'; opts.ModelCoverageObjectives = 'ConditionDecision'; opts.SaveHarnessModel = 'off'; opts.SaveReport = 'off'; [status, fileNames] = sldvrun('sldvexSFCustomCodeExample', opts);
Checking compatibility for test generation: model 'sldvexSFCustomCodeExample'
Compiling model...done
Building model representation...done
'sldvexSFCustomCodeExample' is compatible for test generation with Simulink Design Verifier.
Generating tests using model representation from 24-Jan-2019 17:00:10...
..........
Completed normally.
Generating output files:
Results generation completed.
Data file:
/tmp/BR2019ad_1046204_242911/publish_examples0/tp2eb718db/ex18712703/sldv_output/sldvexSFCustomCodeExample/sldvexSFCustomCodeExample_sldvdata.mat
Используйте функцию sldvruntest, чтобы проверить, что тестовый набор достигает полного покрытия модели.
[~, finalCov] = sldvruntest('sldvexSFCustomCodeExample', fileNames.DataFile, [], true); cvhtml('Final Coverage', finalCov);
Чтобы завершить пример, закройте все модели.
close_system('sldvexSFCustomCodeExample', 0);