Procedures

System Testing for C

You can also use procedures to build more compact test scripts. The following are characteristics of procedures:

  • They must be defined before they are used in scenarios.

  • They do not return any parameters.

A procedure begins with the keyword PROC and ends in the sequence END PROC. For example:

HEADER "Socket Validation", "1.0", "beta"

PROC function ()

...

END PROC

SCENARIO first

...

CALL function ()

...

END SCENARIO

SCENARIO second

SCENARIO level2

FAMILY nominal, structural

...

END SCENARIO

END SCENARIO

A procedure can call sub-procedures as long as these sub-procedures are located above the current procedure.

Procedure blocks can take parameters. When defining a procedure, you must also specify the input/output parameters.

Each parameter is described as a type followed by the name of the variable.

The declaration syntax requires, for each argument, a type identifier and a variable identifier. If you want to use complex data types, you must use either a macro or a C or C++ type declaration.

Example

In the following example, the argument to procedure function1 is a character string of 35 bytes. The arguments to procedure function2 are an integer and a pointer to a character.

HEADER "Socket Validation", "1.0", "beta"

#typedef char string[35];

##define ptr_car char *

PROC function1 (string a)

...

END PROC

PROC function2 (int a, ptr_car b)

...

END PROC

SCENARIO first

...

CALL function1 ( "foo" )

...

END SCENARIO