coder.profile.test.generateCriticalPathTest - Generate tests for critical paths - MATLAB (original) (raw)
Main Content
Generate tests for critical paths
Since R2024a
Syntax
Description
[pathCoverageTest](#mw%5F44fadd07-2bb2-45d9-845b-7e956561b5f4) = coder.profile.test.generateCriticalPathTest([resultsObject](#mw%5Fa1c439d7-a137-49d3-a7f6-5cf2b7432f14),[MaxTime](#mw%5F5a68ba75-d572-4477-b4d0-c4398772b6a9)=100)
generates test cases that execute the critical path of the generated code identified bycoder.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 insldv_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, seeOverview of Signal Loading Techniques and Load Input Data for Basic Test Cases.
Examples
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 thecoder.profile.test.analyzePath
function and store the results inmyResults
.
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
Critical path analysis result, specified as acoder.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
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