Testing a function with an infinite loop

Component Testing for C

You can use the Component Testing feature to test C language functions that contain an infinite loop, that is function with for(;;) or while(1) or similar syntax. If you want to do so, you must use a coverage feature with at least the option logical block and set the option Component testing for C and Ada > Test Compiler > Breaking loop forever for the test to a different value than No.

In such case, the infinite loop is replaced by a stub that should return 0 to break the loop.

The same feature is available with the command line interface of the instrumenter. Use the following option:

  • -SET=TSTWHILELOOP to replace the while infinite loop by a stub
  • -SET=TSTFORLOOP to replace the for infinite loop by a stub
  • -SET=TSTWHILELOOP,TSTFORLOOP for both