Skip to content

The Simulink Model Mutation Testing project provides a framework for generating mutants, and CSV file as an output. It utilizes the MATLAB environment to load the model, apply mutations, and collect outputs.

License

Notifications You must be signed in to change notification settings

haliliceylan/MUT4SLX

Repository files navigation

MUT4SLX

MUT4SLX tool focuses on performing mutation testing on a model implemented in MATLAB/Simulink. It applies various mutation operators to the model and generates Simulink model mutants.

Description

The Simulink Model Mutation Testing project provides a framework for generating mutants, and CSV file as an output. It utilizes the MATLAB environment to load the model, apply mutations, and collect outputs.

DEMO

DEMO

Features

  • Mutant generation: Apply a set of predefined mutation operators to the Simulink model.
  • CVS output generation: Generate an CSV output summarizing the mutations.
  • HTML Report: Please note that the code used to generate this report is not open-sourced yet. Open Report In Browser

Licensing Information

This repository contains code and assets under different licenses: Make sure to review the specific license for each part of the code. Additionally, check out the example use cases with different licenses:

Getting Started

usage: MUT4SLX.py [-h] --model MODEL [--matlab-gui]

Simulink model mutation tool.

optional arguments:
  -h, --help     show this help message and exit
  --model MODEL  Name of the Simulink model in config file.
  --matlab-gui   Show the MATLAB GUI.

Prerequisites

Installation

  1. Clone the repository: git clone https://github.com/haliliceylan/MUT4SLX.git

Usage

  1. Modify the model_files.json file to specify the models and their configurations.
  2. Run the main script: python MUT4SLX.py --model MODEL
  3. View the generated CSV output: open <model_name>.CSV

Configuration File

The configuration file specifies various settings and parameters for using the MUT4SLX tool. It includes a list of mutant operators and configurations for different Simulink models. Let's break down each part of the configuration file:

Mutant Operators For Simulink

The mutant_operators section lists the available mutant operators. These operators are abbreviated with short names for convenience. Here are the mutant operators included in the configuration file:

  • ROR: Relational Operator Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/relationaloperator.html) to the definition of the relational operators in Matlab/Simulink. The ROR operator changes the current value of the block with other different operators, such as changing "==" with "~=, <, <=, >=, >" operators.
  • LOR: Logical Operator Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/logicaloperator.html) to the definition of the logical operators in Matlab/Simulink. The LOR operator changes the block's current value with other different operators, such as changing "AND" with "OR, NAND, NOR, XOR" operators.
  • ASR: Arithmetic Sign Replacement Please refer (https://nl.mathworks.com/help/matlab/relational-operators.html) to the definition of the relational operators in Matlab/Simulink. The ASR operator changes the block's current value with other different operators, such as changing "==" with "~=, <, <=, >=, >" operators.
  • MMR: Min-Max Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/minmax.html) to the definition of the logical operators in Matlab/Simulink. The MMR operator changes the block's current value with other operators, such as changing "MIN" with "MAX" operators.
  • ICR: If Condition Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/if.html) to the definition of the If condition operators in Matlab/Simulink. The ICR operator changes the block's current value with other operators, such as changing an if condition with "1 == 1 (true), 1 == 0 (false)" conditions.
  • TOR: Trigonometric Operator Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/trigonometricfunction.html) to the definition of the trigonometric operators in Matlab/Simulink. The TOR operator changes the block's current value with other operators, such as changing "sin" operator with "cos, tan, asin, acos , atan, sinh, cosh, tanh, asinh, acosh, atanh, cos + jsin" operators.
  • MOR: Math Operator Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/mathfunction.html) to the definition of the Math operators in Matlab/Simulink. The MOR operator changes the block's current value with other operators, such as changing "exp" operator with "log, 10^u, log10, magnitude^2, square, conj, reciprocal, transpose, hermitian" operators.
  • PMR: Product Multiplication Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/product.html) to the definition of the product multiplication types in Matlab/Simulink. The PMR operator changes the block's current value with other operators, such as changing "Element-wise(.)" type with "Matrix()" type.
  • POR: Product Operator Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/product.html) to the definition of the product block in Matlab/Simulink. The POR operator changes the block's current value with other operators, such as changing "2" input types with "* /, / *, //" types.
  • FIR: For Index Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/foriterator.html) to the definition of the For iterator block in Matlab/Simulink. The FIR operator changes the block's current value with other operators, such as changing "Zero-based" type with "One-based" type.
  • FLR: For Limit Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/foriterator.html) to the definition of the For iterator block in Matlab/Simulink. The FLR operator changes the block's current value with other operators, such as changing the current "x" limit value with "x*2" limit value.
  • UDO: Unit Delay Operation Please refer (https://nl.mathworks.com/help/simulink/slref/unitdelay.html) to the definition of the unit delay block in Matlab/Simulink. The UDO operator changes the block's current value with other operators, such as changing "Columns as channels (frame based)" value with "Elements as channels (sample based)" value.
  • SCR: Switch Criteria Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/switch.html) to the definition of the switch block in Matlab/Simulink. The SCR operator changes the block's current value with other operators, such as changing "u2 >= Threshold" value with "u2 ~= 0" value.
  • STR: Switch Threshold Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/switch.html) to the definition of the switch block in Matlab/Simulink. The STR operator changes the block's current value with other operators, such as changing the current "x" threshold value with "x+10" value.
  • CR: Constant Replacement Please refer (https://nl.mathworks.com/help/simulink/slref/constant.html) to the definition of the constant block in Matlab/Simulink. The CR operator changes the block's current value with other operators, such as changing the current "x" value with "x+1, x+10, x+100, x-1, x-10, x-100" values.
{
  "mutant_operators": [
    "ROR",
    "LOR",
    "ASR",
    "MMR",
    "ICR",
    "TOR",
    "MOR",
    "PMR",
    "POR",
    "FIR",
    "FLR",
    "UDO",
    "SCR",
    "STR",
    "CR"
  ],

These operators are used during the mutation process to generate modified versions of the Simulink models for testing.

Mutant Operators For Stateflow

Note: The Stateflow extension has not yet been included in the current version of MUT4SLX. We will release this version soon.

Model Configurations

The configuration file provides settings for different Simulink models. Each model has a unique key, which is used as a reference for specifying the model when running the mutation testing tool. Here are the model configurations included in the file:

The "Heli" section represents a specific configuration for the "Helicopter Control System" Simulink model. The attributes within this section are:

  "Heli": {
    "model": "HelicopterSystem",
    "cd": "matlab_workspace/heli",
    "project": "heli.prj",
    "system": "HelicopterSystem",
    "test": "HeliLoopTest"
  },
  • model: Specifies the main Simulink model to start the mutation process, in this case, "HelicopterSystem."
  • cd: Indicates the relative path of the project directory where the Simulink model is located. It is generally found under the "matlab_workspace" directory with the "heli" subdirectory.
  • project: If the Simulink model depends on a MATLAB project, you can specify the project file using this attribute. In this case, it is "heli.prj."
  • system: Specifies the system name of the main model. It can also accept a full path, allowing the mutation process to start from that path and explore its sub-paths.
  • test: Currently, this attribute is not usable in the current version. However, you can refer to the demo for the full behavior. It represents the test file name for this Simulink model.

Similarly, the configuration sections for other Simulink models like "sf_aircraft," "Aircraft," and "AutotransModel" follow a similar structure, specifying their respective models, directories, systems, and test files if applicable.

Please note that the actual values used in the configuration file, such as model names and paths, are examples provided for demonstration purposes. You should replace them with the appropriate values based on your specific Simulink projects and file structures.

File Structure

  • MUT4SLX.py: This is the main script for performing mutant generation and provides a command-line interface for the tool.
  • model_files.json: This configuration file specifies the models and their details required to run the MUT4SLX tool.
  • matlab_workspace/: This directory contains all MATLAB models and related files.
  • tests/: This directory contains the smoke tests for the tool.
  • HelicopterSystem.html: This is a detailed report on the execution of the Helicopter System mutants. Please note that the code used to generate this report is not open-sourced yet. Open Report In Browser
  • HelicopterSystem_mutants.csv: This CSV file contains information about all the possible mutants generated for the Helicopter System.
  • LICENSE: This file contains the license information for the repository.
  • MutationClasses.py: This file contains the implementation of all mutant operators used by the tool.
  • README.md: This file, which you are currently reading, provides detailed information about the repository.
  • Replication-Package.md: This file contains information about the replication package for the project.
  • config_reader.py: This file includes the implementation of the configuration reader class.
  • .gitignore: This file specifies the files and directories that should be ignored by the Git version control system.

Other supporting files and directories may be present as well.

Example Use Cases

Example use case with Helicopter Control System

(https://github.com/wfpotter/DO178_Case_Study)

Example use case with Aircraft Elevator Control System

(https://gitlab.com/DrishtiYadav/fimtool/-/tree/main/Aircraft_fault_injector/sf_aircraft_model)

Example use case with Automatic Transmission Controller System

(https://gitlab.com/DrishtiYadav/fimtool/-/tree/main/Autotrans_fault_injector/cav_benchmark)

Testing

To run the tests for this project, you can use the following command:

make test # or pytest

Cite This

  1. Ceylan, H. I., Kilincceker, O., Beyazit, M., & Demeyer, S. (2023, September). MUT4SLX: Fast Mutant Generation for Simulink. In 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE) (pp. 2086-2089). IEEE.
  2. Nuyens, S., Ceylan, H. I., Kilincceker, O., Beyazit, M., & Demeyer, S. (2024, March). MUT4SLX: Extensions for Mutation Testing of Stateflow Models. In 2024 IEEE International Conference on Software Analysis, Evolution and Reengineering-Companion (SANER-C) (pp. 215-218). IEEE.

About

The Simulink Model Mutation Testing project provides a framework for generating mutants, and CSV file as an output. It utilizes the MATLAB environment to load the model, apply mutations, and collect outputs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published