Fault Injection in Software Engineering

Fault Injection is a technique for enhancing the testing quality by involving the intentional faults in the software. Fault injection is often in stress testing and it is considered as an important part of developing robust software.

The broadcast of a fault through to an noticeable failure follows a well defined cycle. During execution a fault can cause an error which is not a valid state within a system boundary. 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 as failure.

Classification of Fault Injection:
Fault injection can be categorized into two types on the basis of 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 which 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 testings:

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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.