Main Content

Perform Back-to-Back (MIL/SIL) Equivalence Test for an Atomic Subsystem

This example shows how to create and run a back-to-back test, which is also known as an equivalence test, for an atomic subsystem.

Model with plant and controller subsystems

Generate Code for the Model

Generate code for the entire model.

model = 'sltestMILSILEquivalence'; 
% Configure for code generation
if ismac
    lProdHWDeviceType = 'Intel->x86-64 (Mac OS X)';
elseif isunix
    lProdHWDeviceType = 'Intel->x86-64 (Linux 64)';
    lProdHWDeviceType = 'Intel->x86-64 (Windows64)';
set_param(model, 'ProdHWDeviceType', lProdHWDeviceType);
### Starting build procedure for: sltestMILSILEquivalence
### Successful completion of build procedure for: sltestMILSILEquivalence

Build Summary

Top model targets built:

Model                    Action                        Rebuild Reason                                    
sltestMILSILEquivalence  Code generated and compiled.  Code generation information file does not exist.  

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 25.602s

Create a Back-to-Back Test with the Test For Model Component Wizard

1. Create a new test file and open the Test Manager.

tFile = sltest.testmanager.TestFile('sltestMILSILEquivalence_tests.mldatx'); 

2. Enable coverage collection for the test file. in the Coverage Settings section of the Test Manager, enable Record coverage for system under test under Coverage to Collect and select Decision and MCDC under Coverage Metrics.

Coverage settings

3. Right-click the test file and select New > Test For Model Component.

Right-click menu options

4. Click the Use current model icon to add the Top Model. Select Controller and click the plus sign. Then click Next.

Create test for model component wizard with controller subsystem selected

5. Select Use Design Verifier to generate test input scenarios. Then click Next.

Create Test for model component wizard with Design verifier selected to generate inputs

6. Select Perform back-to-back testing. Check that Simulation1 is set to Normal and Simulation2 is set to Software-in-the-Loop (SIL). Then click Next.

Create test for model component wizard with back-to-back testing selected

7. Click Done on the Generated Test page. The back-to-back (equivalence) test is created.

Test Manager with simulation one set for normal mode

Test Manager with simulation two set for software-in-the-loop mode

Run the Test and View the Results

Select sltestMILSILEquivalence_Harness1. Then click the arrow below Run and select Run Selected Tests.

Test manager showing Run selected tests option location

When the test completes, select Results and view the Summary and Aggregated Coverage Results sections.

Test and coverage results. Coverage is 100%