STUB

C Test Script Language

Purpose

The STUB instruction for C describes all calls to a simulated function in a test script.

Syntax

STUB [<stub_name>.] <function> [<call_range> =>] ([<param_val> {, <param_val> }]) [<return_val>] {, [<call_range> =>] ([<param_val> {, <param_val> }]) [<return_val>] }

Description

The following is described for every parameter of this function and for every expected call:

The optional <call_range> describes one or several successive calls as follows:

<call_num> =>

<call_num> .. <call_num> =>

others =>

 

where <call_num> is the number of the stub call. The keyword others describes any further calls that have not been described. Moreover, this key word allows to not check the sub call number. A <call_num> value of 0 means that there are no calls.

If <call_range> is not specified, then the next call number is assumed.

<function> is the name of the simulated function. It is obligatory. You must previously have described this function in a DEFINE STUB ... END DEFINE STUB block. You can specify in which stub (<stub_name>) the declaration was made.

<param_val> is an expression describing the test values for _in parameters and the returned values for _out parameters. For _inout parameters, <param_val> is expressed in the following way:

(<in_param_val>, <out_param_val>)

<return_val> is an expression describing the value returned by the function if its type is not void. Otherwise, no value is provided.

You must give values for every _in, _out and _inout parameter; otherwise, a warning message is generated. You must not give a value for any _no parameters; otherwise, a warning message is generated.

<param_val> and <return_val> are expressions that can contain:

You must describe at least one call in the STUB instruction. There can be several descriptions, separated by commas (','). STUB instructions can appear in ELEMENT or ENVIRONMENT blocks.

Type Modifier '@' Syntax

In a STUB definition you can use a @ before a type modifier to indicate that this type modifier should be used when generating variable that test the correct execution of STUBs. For example:

DEFINE STUB Example

#void ConstParam (@const int _in *a);

END DEFINE

 

Without the @ symbol, the variables are of const int type and therefore are not modified by the test harness.

Example

STUB open_file ("file1")3

STUB create_file ("file2")4

STUB read_file (3,"line 1")1, (3,"line 2")1, (3,"")0

STUB write_file (4,"line 1")1, (4,"line 2")1

STUB close_file 1=>(3)1, 2=>(4)1