В этом примере показано, как использовать генерацию тестов на модели с пользовательским кодом в диаграмме 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 30-Jul-2020 14:51:55...
..........
Completed normally.
Generating output files:
Results generation completed.
Data file:
/tmp/BR2020bd_1444674_32127/publish_examples4/tpd27f8815/ex18712703/sldv_output/sldvexSFCustomCodeExample/sldvexSFCustomCodeExample_sldvdata.mat
Используйте sldvruntest функция, чтобы проверить, что тестовый набор достигает полного покрытия модели.
[~, finalCov] = sldvruntest('sldvexSFCustomCodeExample', fileNames.DataFile, [], true); cvhtml('Final Coverage', finalCov);
Чтобы завершить пример, закройте все модели.
close_system('sldvexSFCustomCodeExample', 0);