background image
<< Function Prototypes | Modifying Stub Variable Values >>
<< Function Prototypes | Modifying Stub Variable Values >>

Passing Parameters

Automated Testing
If an existing body of stubbed function is encountered, Test RealTime renames the
existing body to atl_stub_
<func ion-name>
and the stubbed version of the function is
used in the test driver.
t
Passing Parameters
Passing parameters by pointer can lead to problems of ambiguity regarding the data
actually passed to the function. For example, a parameter that is described in a
prototype by int *x can be passed in the following way:
int *x as input ==> f(x)
int x as output or input/output ==> f(&x)
int x[10] as input ==> f(x)
int x[10] as output or input/output ==> f(x)
Therefore, to describe the stubs, you should specify the following:
·
The data type in the calling function
·
The method of passing the data
Stub Definition
The following simulation describes a set of function prototypes to be simulated in an
instruction block called DEFINE STUB ... END DEFINE:
HEADER file, 1, 1
BEGIN
DEFINE STUB file
#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
The prototype of each simulated function is described in ANSI form. The following
information is given for each parameter:
·
The type of the calling function (char f[100] for example, meaning that the
calling function supplies a character string as a parameter to the open_file
function)
·
The method of passing the parameter, which can take the following values:
·
_in for an input parameter
·
_out for an output parameter
·
_inout for an input/output parameter
These values describe how the parameter is used by the called function, and,
therefore, the nature of the test to be run in the stub.
·
The _in parameters only will be tested.
143