background image
<< Stub Usage | Creating Complex Stubs in C >>
<< Stub Usage | Creating Complex Stubs in C >>

Replacing Stubs

Test RealTime - User Guide
#foo(1);
#foo(2);
#foo(4);
The first call has a parameter of 1 and returns 1. The second has a a parameter of 2
and returns 2 and the third has a parameter of 3 and returns 3. Anything that does
not match is reported in the test report as a failure.
Sizing Stubs
For each STUB, the Component Testing feature allocates memory to:
·
Store the value of the input parameters during the test
·
Store the values assigned to output parameters before the test
A stub can be called several times during the execution of a test. By default, when
you define a STUB, the Component Testing feature allocates space for 10 calls. If you
call the STUB more than this you must specify the number of expected calls in the
STUB declaration statement.
In the following example, the script allocates storage space for the first 17 calls to the
stub:
DEFINE STUB file 17
#int open_file(char _in f[100]);
#int create_file(char _in f[100]);
#int read_file(int _in fd, char _out l[100]);
#int write_file(int fd, char _in l[100]);
#int close_file(int fd);
END DEFINE
Note You can also reduce the size when running tests on a target platform
that is short on memory resources.
Replacing Stubs
Stubs can be used to replace a component that is still in development. Later in the
development process, you might want to replaced a stubbed component with the
actual source code.
To replace a stub with actual source code:
1.
Right-click the test node and select Add Child and Files
2.
Add the source code files that will replace the Stubbed functions.
3.
If you do not want a new file to be instrumented, right-click the file select
Properties. Set the Instrumentation property to No.
4.
Open the .ptu test script, and remove the STUB sections from your script file.
146