In Rational Test RealTime (RTRT) I want to test function foo() in the sample source code, where I will expect stub call some_Task(), but some_Task() function is present in endless loop.
To handle this endless loop, in order to do that I need to foreclose exit through RTRT from function foo().
I can use setjmp()/longjmp functionality to "exit" a test under certain condition. If some_Task() is stubbed then it can be done.
The below steps explain how to resume the execution of the test script when user code has reached an handled exception:
- stub the function that would put the user program in 'stopped' mode or 'exit'
- resume the execution of the test (using setjmp/longjmp combination)
First of all, the ptu has to include the header file <setjmp.h>
Note the use of '@' that would prevent the PTU parser to search for this file.
At this stage, the compiler header files might not be available.
Then, the setjmp structure has to be declared:
DEFINE STUB PTU_globalvar
Then, a user function has to be stubbed :
DEFINE STUB STUB_c
#void software_failure( )
Then, in the test code include :
@if( ! setjmp( failure_setjump) )
# ret_val = test_call(1, 2);
This should help in forming a test case to handle the endless loops.