Open In App

Fault Injection testing – Software Engineering

Improve
Improve
Like Article
Like
Save
Share
Report

Fault injection is a technique used in software engineering to test the resilience of a software system. The idea is to intentionally introduce errors or faults into the system to see how it reacts and to identify potential weaknesses. This can be achieved in several ways, such as:

  1. Hardware faults: This involves physically altering hardware components to induce faults.
  2. Software faults: This involves intentionally introducing errors into the code, such as incorrect data or incorrect logic.
  3. Network faults: This involves simulating network conditions, such as latency, packet loss, and congestion, to see how the system reacts.

Advantages of fault injection include:

  1. Improved resilience: By testing the system’s resilience to faults, the software development team can identify potential weaknesses and make improvements to ensure the system is more robust.
  2. Increased reliability: By intentionally introducing faults, the software development team can identify and resolve potential issues before they occur in production.
  3. Improved debugging: By intentionally introducing faults, the software development team can more easily identify and debug issues, as the cause of the problem is known.

Disadvantages of fault injection include:

  1. Increased complexity: Fault injection can add complexity to the software development process, making it more difficult for new developers to understand and contribute.
  2. Increased cost: Fault injection can be an expensive process, as additional resources may be needed to simulate faults and monitor the system’s behavior.
  3. Time-consuming: Fault injection can take significant time and effort, as the software development team must carefully plan and execute the tests.

Fault Injection is a technique for enhancing the testing quality by involving intentional faults in the software. Fault injection is often in stress testing, and it is considered an important part of developing robust software. The broadcast of a fault through to a noticeable failure follows a well-defined cycle. During execution, a fault can cause an error that is not a valid state within a system boundary. The same error can cause further errors within the system boundary, hence each new error acts as a fault, and it may propagate to the system boundary and be observable. When an error state is observed at the system boundary that is called a failure. Classification of Fault Injection: Fault injection can be categorized into two types based on software implementation: Compile-time fault injection and Run-time fault injection.

These are explained as following below.

1. Compile-time fault injection: Compile-time fault injection is a fault injection technique in which source code is modified to inject imitated faults into a system. Two methods are used to implement fault while compile time:

  • Code Modification: Mutation testing is used to change existing lines of code so that there may exist faults. Code mutation produces faults that are similar to the faults unintentionally done by programmers. Example:
Original Code:
int main()
{
int a = 10;
while ( a > 0 )
{
cout << "GFG";
a = a - 1;
}
return 0;
}

Modified Code:
int main()
{
int a = 10;
while ( a > 0 )
{
cout << "GFG";
a = a + 1; // '-' is changed to '+'
}
return 0;
}

  • Now it can be observed that value of a will increase and “while loop” will never terminate and program will go into an infinite loop.
  • Code Insertion: A second method of code mutation is code insertion fault injection which adds code instead of modifying existing code. This is basically done by the use of anxiety functions which are simple functions which take an existing value and change it via some logic into another value. Example:
Original Code:
int main()
{
int a = 10;
while ( a > 0 )
{
cout << "GFG";
a = a - 1;
}
return 0;
}

Modified Code:
int main()
{
int a = 10;
while ( a > 0 )
{
cout << "GFG";
a = a - 1;
a++; // Additional code
}
return 0;
}
  • Now it can be observed that value of a will be fixed and “while loop” will never terminate and program will go into an infinite loop.

2. Run-time fault injection: Run-time fault injection technique uses a software trigger to inject a fault into a running software system. Faults can be injected via a number of physical methods and triggers can be implemented in different ways. Software Triggers used in Run-time fault injection:

1. Time Based Triggers
2. Interrupt Based Triggers

3 methods are used to inject fault while run-time:

  1. Corrupting memory space: This method involves corrupting main memory and processor registers.
  2. System call interposition: This method is related with the fault imitation from operating system kernel interfaces to executing system software. This is done by intercepting operating system calls made by user-level software and injecting faults into them.
  3. Network level: This method is related with the corrupting, loss or reordering of network packets at the network interface.

Fault Injection in different software testing:

  • (a) Robustness Testing – In robustness testing fault injection is used.
  • (b) Stress Testing – fault injection is also used in stress testing.

Advantages of fault injection in software engineering:

  1. Improved resilience: By testing the system’s resilience to faults, the software development team can identify potential weaknesses and make improvements to ensure the system is more robust.
  2. Increased reliability: By intentionally introducing faults, the software development team can identify and resolve potential issues before they occur in production.
  3. Improved debugging: By intentionally introducing faults, the software development team can more easily identify and debug issues, as the cause of the problem is known.
  4. Realistic testing: Fault injection provides a more realistic test of the software system, as it simulates real-world scenarios and conditions.

Disadvantages of fault injection in software engineering:

  1. Increased complexity: Fault injection can add complexity to the software development process, making it more difficult for new developers to understand and contribute.
  2. Increased cost: Fault injection can be an expensive process, as additional resources may be needed to simulate faults and monitor the system’s behaviour.
  3. Time-consuming: Fault injection can take significant time and effort, as the software development team must carefully plan and execute the tests.
  4. Safety concerns: In some cases, fault injection may pose a risk to the system, for example, if hardware is physically altered. Careful planning and execution is necessary to ensure the safety of the system.

Last Updated : 11 Dec, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads