Sending Messages

System Testing for C

PROCSEND Instruction

Event management provides a mechanism to send messages. This mechanism needs the definition of a message sending procedure or PROCSEND for each couple communication type, message type.

The PROCSEND instruction is then called automatically by the SEND instruction to sends a message to the system under test (SUT).

In the following example, msg is a message_t typed input formal parameter specifying the message to send. The input formal parameter id is used to know where to send the message on the communication type appl_comm.

PROCSEND message_t: msg ON appl_comm: id

   CALL mbx_send_message ( &id, &msg ) @ err_ok



The sending is done by the API function call to mbx_send_message. The return code is treated to decide whether the message was correctly sent. Another value than err_ok  means that an error occurred during the sending.

The script must have one PROCSEND for each message type and channel type pair used by any of the SEND instructions.

The name of each PROCSEND in the generated C code is made up with the signature of the message type and channel type for each PROCSEND found in the test script, as follows.

VAR Instruction

The instruction VAR allows you to initialize messages declared using MESSAGE instructions. This message may also be initialized by any other C or C++ function or method:

VAR ack, INIT= { type => ACK }

VAR data, INIT= {

& type => DATA,

& applname => "SATURN",

& userdata => "hello world !" }


To learn all the nuts and bolts of the DEF_MESSAGE Instruction, see the Messages and Data Management chapter.

SEND Instruction

This instruction allows you to invoke a message sending on one communication channel .

It has two arguments:

The send instruction is as follows:

SEND ( message , appl_ch )


In the previous figure, the SEND instruction allows the test program to send a message on a known connection  (see the ADD_ID instruction). If an error occurs during the sending of the message, the SEND exits with an error. The scenario execution is then interrupted.

To send the message on the appropriate channel, the generated code calls the PROCSEND named with the signature of the message type to be sent (first parameter) and the channel type to be used (second parameter).

The message type is provided by the MESSAGE instruction. The channel type is provided by the CHANNEL instruction.

Therefore, in the generated code, the SEND instruction calls the following function:

PROCSEND_message_t_appl_comm(message, appl_ch)

which corresponds to the following line in the test script:

PROCSEND message_t ... ON appl_comm


The following test script describes a simple use of our stack. First of all, some resources are allocated and a connection is established with the communication stack (mbx_init). This connection is made known by the Virtual Tester with the ADD_ID instruction. Then, the Virtual Tester registers (mbx_register) onto the stack by giving its application name (JUPITER). The Virtual Tester sends a message to an application under test (SATURN). Finally, the Virtual Testers unregisters itself (mbx_unregister) and frees the allocated resources (mbx_end).



HEADER "SystemTest 1st example: sending a message","1.0",""

COMMTYPE appl_comm IS appl_id_t

MESSAGE message_t: message, ack, data, neg_ack

CHANNEL appl_comm: appl_ch

#appl_id_t id;

#int errcode;

PROCSEND message_t: msg ON appl_comm: id

   CALL mbx_send_message ( &id, &msg) @ err_ok


SCENARIO first_scenario

FAMILY nominal

   COMMENT  Initialize, register, send data

   COMMENT  wait acknowledgement, unregister and release

   CALL mbx_init(&id) @ err_ok @ errcode


   VAR id.applname, INIT="JUPITER"

   CALL mbx_register(&id) @ err_ok @ errcode

   VAR message, INIT={

& type=>DATA,

& applname=>"SATURN",

& userdata=>"hello Saturn!"}

   SEND ( message, appl_ch )

   CALL mbx_unregister(&id) @ err_ok @ errcode


   CALL mbx_end(&id) @ err_ok @ errcode