Main Content

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 TestTop model
Simulation Mode Normal
SIL/PIL ModeSoftware-in-the-Loop (SIL)

After exporting the test case, these settings are in the Test Manager for SIMULATION 1.

PropertySettingLocation in Test Manager
ModelTop modelSIMULATION 1 > SYSTEM UNDER TEST
Simulation modeNormalSIMULATION 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.

PropertySettingLocation in Test Manager
ModelTop modelSIMULATION 2 > SYSTEM UNDER TEST
Simulation modeSoftware-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 TestModel blocks in SIL/PIL mode
Top Model Mode Normal

After exporting the test case, these settings are in the Test Manager for SIMULATION 1.

PropertySettingLocation in Test Manager
ModelTop modelSIMULATION 1 > SYSTEM UNDER TEST
Simulation modeNormalSIMULATION 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.

PropertySettingLocation in Test Manager
ModelTop modelSIMULATION 2 > SYSTEM UNDER TEST
Simulation mode

Normal

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.

PropertySettingLocation in Test Manager
ModelModel block nameSIMULATION 1 > SYSTEM UNDER TEST
HarnessHarness nameSIMULATION 1 > SYSTEM UNDER TEST > TEST HARNESS
Simulation modeNormalSIMULATION 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.

PropertySettingLocation in Test Manager
ModelModel block nameSIMULATION 2 > SYSTEM UNDER TEST
HarnessHarness nameSIMULATION 2 > SYSTEM UNDER TEST > TEST HARNESS
Simulation modeSoftware-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.

  1. Open the TopModelCode model. At the command line, enter:

    openExample('simulinkcoder/FilePackagingModelsCodeAndDataExample', ...
     'supportingFile', 'TopModelCode');
    

    Model with three counter model blocks

    Note

    Steps 2 through 4 apply specifically to this TopModelCode model. These steps might not be needed for other models.

  2. For this model, click Signal Table in the Simulation tab. Select Test Point and Log data for the CounterA, CounterB, and CounterC signals.

    Model data editor with test points and log data selected

  3. 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.

  4. 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.

  5. Expand the Apps tab in the model window and click SIL/PIL Manager under Code Verification, Validation, and Test.

    Apps tab with SIL PIL Manager highlighted

  6. In the SIL/PIL Manager toolstrip, if they are not already selected, select

    • Automated Verification

    • System Under TestTop Model

    • Simulation ModeNormal

    • SIL/PIL ModeSoftware-in-the-Loop (SIL)

    SIL PIL Manager toolstrip

  7. To export the test case, expand Compare Runs and click Export to Test Manager.

    Toolstrip with Export to Test Manager highlighted

  8. In the Export SIL/PIL Test Cases dialog box, use the default values and click OK. The Test Manager opens.

  9. In the Test Manager, to see the imported test case and settings, expand TopModelCode_TestFile and SIL/PIL Test Suite in the Test Browser.

    Test browser pane with expanded hierarchy

  10. 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 is

    System under test with specified simulation mode

  11. Open the Equivalence Criteria section and click Capture. The model simulates and the section lists the signals to compare in the test case.

    Equivalence criteria table

  12. Click Run to run the test case.

  13. In the Test Manager, the Results and Artifacts panel shows the pass/fail results. A Code Generation Report opens in a separate window.

  14. Select one or more signals to plot the results.

    Results plot for Counter A

The plot shows that the outputs from the two simulations are the same.

Related Topics