Testing stub order

When multiple stubs are called, it is possible to test the number of stub calls and the order of stub calls by using the two following global variables:

  • STUBCALL_NB: integer variable gives the number of stubs that is called during a test. The default value is 0.
  • STUBCALLORDERS: array on pointers on function giving the ordered list of stubs that is called during a test. The default value is 0 for all element of this array.

The default size of the array is 10. It can be modified by introducing the following macro at the beginning of the test script:##define STUB_CALL_IDX_MAX 25

In a test, the number of stub calls can be tested with the following instruction:

VAR STUBCALL_NB, INIT=0, EV=4

Note: init=0 is required to activate this feature and check the total number of stub calls.

The sub calls order can be tested with the following instruction:

ARRAY STUBCALLORDERS, INIT==, EV={

& addition_add,

& addition_sub,

& multiplication_multiplication,

& addition_add,

& others=>0}

Each element of the array is composed as following <stub block name>_<function name>. In the previous example, the following stubs are declared at the beginning of the script: DEFINE STUB addition

#int add(int _in b, int _in c);

#int sub(int _in b, int _in c);

END DEFINE

DEFINE STUB multiplication

#int multiplication(int _in a, int _in b);

END DEFINE