Import Test Cases for Equivalence Testing
You can use the SIL/PIL Manager app in Embedded Coder® to export test cases to the Test Manager. By using the app to export software-in-the-loop (SIL) or processor-in-the-loop (PIL) test cases, you do not have to write complicated test scripts for back-to-back testing.
Note
You need both Simulink® Test™ and Embedded Coder to use this feature.
Using Export to Test Manager in the SIL/PIL Manager app in Automated Verification mode exports a test case with two simulations, each in a different simulation mode. For back-to-back testing, you usually use Normal mode and SIL mode or Normal mode and PIL mode. When you export from the app, the Test Manager opens with the new equivalence test case in the Test Browser pane. If you export to a new test file, the Test Browser opens with a new test file and a new test suite for the test case. The test case includes a panel for each simulation (SIMULATION 1 and SIMULATION 2). See SIL/PIL Manager (Embedded Coder) and SIL/PIL Manager Verification Workflow (Embedded Coder) for information on how to use the app to export a test case.
Settings for Test Case Simulations
The System Under Test in the SIL/PIL Manager app determines the settings for the test case simulations in the Test Manager. These settings for each type of system under test are described for exporting a test case that includes a SIL mode simulation. For a test that includes a PIL mode simulation, the settings are the same for each type of system under test.
Top-Level Model
When the system under test is a Top model
, the exported
test case tests the entire model. The Test Harness field in Test Manager is
blank.
Before exporting the test case, these settings are in the SIL/PIL Manager app.
System Under Test | Top model |
Simulation Mode | Normal |
SIL/PIL Mode | Software-in-the-Loop (SIL) |
After exporting the test case, these settings are in the Test Manager for SIMULATION 1.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Top model | SIMULATION 1 > SYSTEM UNDER TEST |
Simulation mode | Normal | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Selected To run the simulation in Normal mode, model blocks set to SIL/PIL mode are overridden. | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
After exporting the test case, these settings are in the Test Manager for SIMULATION 2.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Top model | SIMULATION 2 > SYSTEM UNDER TEST |
Simulation mode | Software-in-the-Loop (SIL) | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Not selected The model blocks set to SIL or PIL mode run in SIL or PIL mode, respectively. | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Model Block in SIL/PIL Mode
When the system under test is Model blocks in SIL/PIL
mode
, the exported test case is a Model block in
SIL or PIL simulation mode. The Test Harness field in Test Manager is blank.
Before exporting the test case, these settings are in the SIL/PIL Manager app.
System Under Test | Model blocks in SIL/PIL
mode |
Top Model Mode | Normal |
After exporting the test case, these settings are in the Test Manager for SIMULATION 1.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Top model | SIMULATION 1 > SYSTEM UNDER TEST |
Simulation mode | Normal | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Selected To run the simulation in Normal mode, model blocks set to SIL/PIL mode are overridden. | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
After exporting the test case, these settings are in the Test Manager for SIMULATION 2.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Top model | SIMULATION 2 > SYSTEM UNDER TEST |
Simulation mode |
The system under test runs in SIL or PIL mode as set in the SIL/PIL Manager app. Other blocks run in Normal mode. | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Not selected The model blocks set to SIL or PIL mode run in SIL or PIL mode, respectively. | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Model Block or Reusable Library Subsystem in a Test Harness
When the system under test is a Model block or a reusable library subsystem in a test harness, the exported test case is that block or subsystem in SIL or PIL simulation mode. Use the SIL/PIL Manager app from within the test harness.
Before exporting the test case, these settings are in the SIL/PIL Manager app.
System Under Test | Name of Model block or reusable library subsystem in the test harness. This field is not editable because you cannot change an entire harness to SIL/PIL mode. |
Simulation Mode | Normal |
SIL/PIL Mode | Software-in-the-Loop (SIL) |
After exporting the test case, these settings are in the Test Manager for SIMULATION 1.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Model block name | SIMULATION 1 > SYSTEM UNDER TEST |
Harness | Harness name | SIMULATION 1 > SYSTEM UNDER TEST > TEST HARNESS |
Simulation mode | Normal | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Selected To run the simulation in Normal mode, Model blocks set to SIL/PIL mode are overridden. | SIMULATION 1 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
After exporting the test case, these settings are in the Test Manager for SIMULATION 2.
Property | Setting | Location in Test Manager |
---|---|---|
Model | Model block name | SIMULATION 2 > SYSTEM UNDER TEST |
Harness | Harness name | SIMULATION 2 > SYSTEM UNDER TEST > TEST HARNESS |
Simulation mode | Software-in-the-Loop (SIL) | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Override model blocks in SIL/PIL to normal mode | Not selected The Model blocks set to SIL or PIL mode run in SIL or PIL mode, respectively. | SIMULATION 2 > SYSTEM UNDER TEST > SIMULATION SETTING OVERRIDES |
Back-to-Back Testing a Model Using the SIL/PIL Manager App
This example shows how to perform back-to-back testing with a test case exported from the Embedded Coder SIL/PIL Manager app. The test case compares a model simulated in Normal mode and in Software-in-the-Loop (SIL) mode.
Open the
TopModelCode
model. At the command line, enter:openExample('simulinkcoder/FilePackagingModelsCodeAndDataExample', ... 'supportingFile', 'TopModelCode');
Note
Steps 2 through 4 apply specifically to this
TopModelCode
model. These steps might not be needed for other models.For this model, click Signal Table in the Simulation tab. Select Test Point and Log data for the CounterA, CounterB, and CounterC signals.
Right-click in the model and select Model Configuration Parameters. In the Configuration Parameters dialog box,
In Data Import/Export, set the Format to
Dataset
.In Code Generation > Interface, select signals in the Generate C API for section.
Click OK.
Right-click on the Model blocks and select Open as Top Model. In the Configuration Parameters dialog box, set the same items as in Step 3.
Expand the Apps tab in the model window and click SIL/PIL Manager under Code Verification, Validation, and Test.
In the SIL/PIL Manager toolstrip, if they are not already selected, select
Automated Verification
System Under Test —
Top Model
Simulation Mode —
Normal
SIL/PIL Mode —
Software-in-the-Loop (SIL)
To export the test case, expand Compare Runs and click Export to Test Manager.
In the Export SIL/PIL Test Cases dialog box, use the default values and click OK. The Test Manager opens.
In the Test Manager, to see the imported test case and settings, expand
TopModelCode_TestFile
andSIL/PIL Test Suite
in the Test Browser.Select the
SIL/PIL Equivalence
test case. To see the settings for the simulation modes, expand the SIMULATION 1 and SIMULATION 2 sections. The expanded SIMULATION 1 section isOpen the Equivalence Criteria section and click Capture. The model simulates and the section lists the signals to compare in the test case.
Click Run to run the test case.
In the Test Manager, the Results and Artifacts panel shows the pass/fail results. A Code Generation Report opens in a separate window.
Select one or more signals to plot the results.
The plot shows that the outputs from the two simulations are the same.
Related Topics
- SIL/PIL Manager (Embedded Coder)
- SIL/PIL Manager Verification Workflow (Embedded Coder)
- Code Verification Through Software-in-the-Loop and Processor-in-the-Loop Execution (Embedded Coder)