background image
<< Creating Complex Stubs in C | Simulating Functions with Varying Parameters >>
<< Creating Complex Stubs in C | Simulating Functions with Varying Parameters >>

Functions Containing Type Modifiers

Test RealTime - User Guide
#int create_file(char _in f[100]);
#int read_file(int _no fd, char _inout l[100]);
#int write_file(int _no fd, char _in l[100]);
#int close_file(int _no fd);
END DEFINE
...
STUB open_file ("file1")3
STUB create_file ("file2")4
STUB read_file (("","line 1"))1, (("line 1","line 2"))1,
& (("line2",""))0
STUB write_file ("line 1")1, ("line 2")1
STUB close_file ()1, ()1
If a stub is called and if it has not been declared in a scenario, an error is raised in the
report because the number of the calls of each stub is always checked.
Functions Using _inout Mode Arrays
To stub a function taking an array in _inout mode, you must provide storage space
for the actual parameters of the function.
The function prototype in the .ptu test script remains as usual:
#extern void function(unsigned char *table);
The DEFINE STUB statement however is slightly modified:
DEFINE STUB Funct
#void function(unsigned char _inout table[10]);
END DEFINE
The declaration of the pointer as an array with explicit size is necessary to memorize
the actual parameters when calling the stubbed function. For each call you must
specify the exact number of required array elements.
ELEMENT
STUB Funct.function 1 => (({'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 0x0},
& {'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', 0x0}))
#call_the_code_under_test();
END ELEMENT
This naming convention compares the actual values and not the pointers.
The following line shows how to pass _inout parameters:
({<in_parameter>},{<out_parameter>})
Functions Containing Type Modifiers
Type modifiers can appear in the signature of the function but should not be used
when manipulating any passed variables. When using type modifiers, add @ prefix
to the type modifier keyword.
Test RealTime recognizes @-prefixed type modifiers in the function prototype, but
ignores them when dealing internally with the parameters passed to and from the
function.
148