Main Content

coder.profile.test.generateCriticalPathTest

Generate tests for critical paths

Since R2024a

Description

example

pathCoverageTest = coder.profile.test.generateCriticalPathTest(resultsObject,MaxTime=100) generates test cases that execute the critical path of the generated code identified by coder.profile.test.analyzePath using Simulink® Design Verifier™. The function uses the maximum time specified in MaxTime for test generation. The function can generate test cases only if the path contains conditional subsystems or blocks with decision conditions for execution from this list.

  • Switch

  • If Action Subsystem

  • Multiport Switch

  • Switch Case

  • For Iterator

  • While Iterator

  • Enabled Subsystem

  • Triggered Subsystem

  • Enabled and Triggered Subsystem

The coder.profile.test.generateCriticalPathTest function saves the generated test cases in both a MAT data file and a Simulink Test™ compatible MLDATX file. The files are saved in sldv_output/modelName folder, where modelName is the name of your model.

If you have a Simulink Test license, you can use the MLDATX file directly for execution-time analysis. If you do not have a Simulink Test license, you can import the test cases in the MAT data file to your model as inputs and use those for analysis. For more information on importing data into a model, see Overview of Signal Loading Techniques and Load Input Data for Basic Test Cases.

Examples

collapse all

Use coder.profile.test.generateCriticalPathTest to generate tests for critical paths.

Open the CriticalPathIdentify model.

openExample('CriticalPathIdentify');
model = "CriticalPathIdentify";

Identify the critical path of the generated code by using the coder.profile.test.analyzePath function and store the results in myResults.

myResults = coder.profile.test.analyzePath(model,SimMode="SIL")

Generate tests for the identified path using this command:

myTestFile = coder.profile.test.generateCriticalPathTest(myResults)
Data file:
 /users/sldv_output/CriticalPathIdentify/CriticalPathIdentify_sldvdata.mat

myTestFile =

 '/users/sldv_output/CriticalPathIdentify/CriticalPathIdentify_test.mldatx'

Input Arguments

collapse all

Critical path analysis result, specified as a coder.profile.ExecutionTimeSet object. This object is returned by the coder.profile.test.analyzePath function. The object stores the identified critical path and the estimated cost percentages of code sections in the critical path.

Use the Code Profile Analyzer to review the results stored in the object.

Maximum time for test generation, specified as a positive integer.

MaxTime specifies the maximum time in seconds for test generation. If the specified time is not sufficient for test generation, the function issues an error and suggests increasing the MaxTime value.

Example: pathCoverageTest = coder.profile.test.generateCriticalPathTest(resultsObject,MaxTime=50)

Output Arguments

collapse all

Path of the MLDATX test file, returned as a character vector. The function also returns a path to the MAT data file containing the generated test cases.

Version History

Introduced in R2024a