Create and Run Back-to-Back Tests Using Enhanced MCDC
This example shows you how to create and run a back-to-back test using enhanced MCDC. Enhanced MCDC analyzes the detectability of each objective in the model and generates non-masking test cases for each objective. For more information, see Enhanced MCDC Coverage in Simulink Design Verifier.
Back-to-back tests in Simulink® Test™ compare the results of normal simulations with the generated code results from software-in-the-loop, processor-in-the-loop, or hardware-in-the-loop simulations.
Section 1: Prepare the Model
1. Open the model:
model = ('sldvSliceCruiseControl');
open_system(model);
2. Prepare the model for code generation and logging.
set_param(model, 'ProdHWDeviceType', 'Intel->x86-64 (Linux 64)'); set_param(model, 'ProdLongLongMode', 'on'); set_param(model, 'SaveOutput', 'on'); set_param(model, 'SignalLogging', 'on'); set_param(model, 'SaveFormat', 'Dataset');
Note: You can also optionally mark internal signals in the model as test-pointed logged signals (for example, sldvSliceCruiseControl/CruiseControlMode/opMode/Switch
,) so that these signals are prioritized as detection sites during the enhanced MCDC analysis. For more information, see Configure Detection Sites using Test-pointed Logged Signals.
3. Generate the code.
In the Apps tab, click Embedded Coder, and then click Generate Code.
Embedded coder® generates the code generation report for model. Close the generated report window. Simulink Design Verifier uses information on logged signals from the generated code to configure the detection sites for enhanced MCDC. If you do not generate the code, Simulink Design Verifier uses the information on test-pointed logged signals from the model to configure the detection sites for enhanced MCDC.
Section 2: Create Back-to-Back Tests Using Enhanced MCDC
Follow these steps to create back-to-back tests in the Simulink Test Test Manager:
1. To open the Simulink Test tab, in the Apps tab, in the Model Verification, Validation, and Test section, click Simulink Test.
2. To open the Test Manager, in the Tests tab, click Simulink Test Manager.
3. Click New > Test for Model Component. The Create Test for Model Component wizard opens.
4. To specify the Top Model to test, fill the fields by clicking the Use currently selected model component button next to the Top Model field.
5. Click Next to specify how to use the Simulink Design Verifier to generate test inputs. Select Use Design Verifier to generate test input scenarios. This option runs the model and creates inputs using Simulink Design Verifier.
6. Click Next to select the testing method. Select Perform back-to-back testing. For Simulation1, select Normal
. For Simulation2, select Software-in-the-Loop (SIL)
. Select Set Model coverage objectives as Enhanced MCDC.
7. Click Next to specify the input source, format, and where to save the test data and generated tests. For Specify the file format, select MAT. For Specify location to save test data, use the default location name.
8. Click Done. Simulink Test creates the test cases and closes the wizard.
Section 3: Run Back-to-Back Tests
To run the back-to-back test, click Run in Simulink Test Manager.
Clean Up
To complete the example, close the model.
bdclose(model);