Documentation Center

  • Trial Software
  • Product Updates

Testing a Fuel Rate Controller Using Simulink® Design Verifier™ Test Data

This example shows how to use SystemTest™ to execute test data generated by Simulink Design Verifier. SystemTest verifies that an appropriate amount of Decision, Condition, and MCDC coverage is obtained for a fuel rate controller.

The test data generated by Simulink Design Verifier is converted to an Excel® spreadsheet, which is then used by SystemTest, which runs the test data on the original Simulink® model. This bypasses the need to create a test harness model and Signal Builder block.

This example requires the following products to run:

  • Simulink

  • Simulink® Verification and Validation™

  • Stateflow®

Open the example in the SystemTest desktop.Open the example in the SystemTest desktop.

Simulink Model Overview

The following Simulink model of a fuel rate controller was analyzed by Simulink Design Verifier using an exhaustive search technique to generate input test data. This model was configured to generate a MAT-file containing tests cases that satisfy Decision, Condition, and MCDC coverage. Each test case consists of a test signal for each of the 4 Inport blocks, representing:

  • Throttle angle

  • Speed

  • Exhaust gas (EGO)

  • Manifold absolute pressure (MAP)

demosystest_fuelctrlsldv_model

Access Simulink Design Verifier Test Data

Typically, a new harness model containing a Signal Builder block would need to be created in order to run the generated test data and verify analysis objectives are satisfied. However, by converting the generated test data into an Excel file, you can easily access these test cases from SystemTest using a Spreadsheet Data test vector.

The following code loads the MAT-file created by Simulink Design Verifier, which stores the generated test data in a variable named sldvData, and converts it into an Excel spreadsheet where each sheet contains one test case.

% Suppress the "new sheet added" warning from XLSWRITE.
warningState = warning('query', 'MATLAB:xlswrite:AddSheet');
warning('off', 'MATLAB:xlswrite:AddSheet');

% Iterate through each test case.
load('st_fuelctrlsldv_data.mat')
numTests = length(sldvData.TestCases);

for iTest = 1:numTests
    % Define the spreadsheet header and data.
    iTestCase = sldvData.TestCases(iTest);
    sheetHeaders = ['Time' iTestCase.signalLabels'];
    testData = [iTestCase.timeValues; vertcat(iTestCase.dataValues{:})]';

    % Write the data out as columns in a new Excel sheet.
    sheetData = [sheetHeaders; num2cell(testData)];
    fprintf('Writing test case %d of %d...\n', iTest, numTests);
    xlswrite('sldvdata.xls', sheetData, iTest);
end

% Restore the warning state.
warning(warningState);
Writing test case 1 of 37...
Writing test case 2 of 37...
Writing test case 3 of 37...
Writing test case 4 of 37...
Writing test case 5 of 37...
Writing test case 6 of 37...
Writing test case 7 of 37...
Writing test case 8 of 37...
Writing test case 9 of 37...
Writing test case 10 of 37...
Writing test case 11 of 37...
Writing test case 12 of 37...
Writing test case 13 of 37...
Writing test case 14 of 37...
Writing test case 15 of 37...
Writing test case 16 of 37...
Writing test case 17 of 37...
Writing test case 18 of 37...
Writing test case 19 of 37...
Writing test case 20 of 37...
Writing test case 21 of 37...
Writing test case 22 of 37...
Writing test case 23 of 37...
Writing test case 24 of 37...
Writing test case 25 of 37...
Writing test case 26 of 37...
Writing test case 27 of 37...
Writing test case 28 of 37...
Writing test case 29 of 37...
Writing test case 30 of 37...
Writing test case 31 of 37...
Writing test case 32 of 37...
Writing test case 33 of 37...
Writing test case 34 of 37...
Writing test case 35 of 37...
Writing test case 36 of 37...
Writing test case 37 of 37...

SystemTest TEST-File Overview

The demosystest_fuelctrlsldv TEST-file has been set up to read the generated Excel file and run all the test cases generated by Simulink Design Verifier. It has also been set up to collect model coverage metrics for the model.

To create this test, 3 steps are involved:

  1. Read Excel test data into SystemTest

  2. Map test signals to Simulink Inport blocks

  3. Configure model coverage settings

Part 1: Read Excel Test Data Into SystemTest

The first step involves reading Excel data into a SystemTest test vector. The following video will highlight how to:

  • Create a Spreadsheet Data test vector

  • Configure the Spreadsheet Data test vector to read test data from the Excel file

Watch the video (1 min, 59 sec)Watch the video (1 min, 59 sec)

Part 2: Map Test Signals to Simulink Inport Blocks

The second step involves assigning test signals read from Excel to individual Simulink Inport blocks. The following video will highlight how to:

  • Create a Simulink element

  • Map the test signals individually to the root-level Inport blocks

Watch the video (2 min, 10 sec)Watch the video (2 min, 10 sec)

Part 3: Configure Model Coverage Settings

The last step involves configuring model coverage settings. Model coverage can be enabled by using the model coverage tab in the Simulink element. This tab should be configured to look as follows:

Run the Test

To run the TEST-file from the command line, use the strun function. After the test has completed, a model coverage report is created describing the cumulative coverage results. This report can be used to document the amount of Decision, Condition, and MCDC coverage achieved.

strun('demosystest_fuelctrlsldv.test');
fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

DEC
fuel_mode =
    2

fail_state[SPEED] =
     0

fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

DEC
fuel_mode =
    2

fail_state[SPEED] =
     0

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

DEC
fail_state[SPEED] =
     0

fuel_mode =
    3

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
DEC
fail_state[SPEED] =
     0

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

DEC
fail_state[PRESS] =
     0

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
DEC
INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

DEC
fail_state[PRESS] =
     0

DEC
fuel_mode =
    2

DEC
fail_state[SPEED] =
     0

fuel_mode =
    1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fuel_mode =
    3

INC
fail_state[PRESS] =
     1

DEC
fuel_mode =
    2

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fuel_mode =
    3

INC
fail_state[PRESS] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

fuel_mode =
    1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

DEC
fuel_mode =
    2

fail_state[SPEED] =
     0

fuel_mode =
    3

fuel_mode =
    2

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

DEC
fuel_mode =
    2

fail_state[PRESS] =
     0

DEC
fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

fail_state[SPEED] =
     1

DEC
fuel_mode =
    2

fail_state[PRESS] =
     0

DEC
fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    2

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

DEC
fuel_mode =
    2

fail_state[PRESS] =
     0

DEC
fuel_mode =
    1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

DEC
fail_state[PRESS] =
     0

DEC
fuel_mode =
    2

DEC
fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

INC
fuel_mode =
    1

fuel_mode =
    2

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

INC
fail_state[PRESS] =
     1

INC
DEC
fuel_mode =
    1

fail_state[PRESS] =
     0

DEC
INC
fail_state[SPEED] =
     1

fuel_mode =
    2

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

INC
fail_state[PRESS] =
     1

INC
DEC
fuel_mode =
    1

fail_state[PRESS] =
     0

DEC
fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[PRESS] =
     1

INC
fuel_mode =
    3

INC
fail_state[SPEED] =
     1

DEC
DEC
fuel_mode =
    2

fail_state[SPEED] =
     0

fuel_mode =
    3

DEC
fail_state[PRESS] =
     0

INC
INC
fail_state[SPEED] =
     1

INC
INC
fail_state[PRESS] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
DEC
DEC
fuel_mode =
    2

fail_state[PRESS] =
     0

DEC
fail_state[SPEED] =
     0

fuel_mode =
    3

INC
fail_state[PRESS] =
     1

INC
INC
fail_state[SPEED] =
     1

INC
DEC
fail_state[PRESS] =
     0

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
DEC
fail_state[PRESS] =
     0

DEC
fuel_mode =
    2

INC
fuel_mode =
    3

fail_state[PRESS] =
     1

INC
DEC
INC
DEC
fail_state[SPEED] =
     0

DEC
fuel_mode =
    2

DEC
fail_state[PRESS] =
     0

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

fail_state[PRESS] =
     0

fail_state[SPEED] =
     0

fuel_mode =
    1

INC
fail_state[SPEED] =
     1

DEC
fail_state[SPEED] =
     0

fuel_mode =
    3

INC
INC
fail_state[SPEED] =
     1

INC
fail_state[PRESS] =
     1

DEC
fail_state[PRESS] =
     0

DEC
DEC
fail_state[SPEED] =
     0

fuel_mode =
    1

INC
INC
fuel_mode =
    3

fail_state[SPEED] =
     1

Was this topic helpful?