# check

The keyword denotes a generic communication operation that allows read access to the top element of message-based and procedure-based incoming port queues without removing the top element from the queue. It can be used to check the top element of the port queue or to check whether anything waits for processing in the port queue

- If the queue is empty, the operation fails.

Related keywords:

- any
- catch
- getcall
- getreply
- port
- receive
- from
- sender

#### 1. Checking the top element of the port queue

### port_reference.check ( communication_operation );

- port_reference points out the port where the procedure or message is awaited.

  - the keywords any port may be used to indicate that communication through any port will be accepted (see the example 4).

- The check keyword introduces the queue verification.

- The communication_operation may be one of the following :

  - catch (see the example1);
  - getcall (see the example 2);
  - getreply (see the example 3);
  - receive (see the example 4).

#### 2. Checking whether anything waits for processing in the port queue

### port_reference.check [ from address_reference ] [ -> sender address_reference ];

- port_reference points out the port where the procedure or message is awaited.

  - the keywords any port may be used to indicate that communication through any port will be accepted (see the example 6).

- The check keyword introduces the queue verification.

- The optional from keyword is used when a port is connected to several entities and restriction to one communication partner is required (see the example 6).

- The optional sender keyword is used to store the address of the sender (see the example 7).

- address_reference is one of the following:

  - a component reference (cf. create) or the keyword system, in case of one-to-many connections.

  - an address reference (cf. address) , when there are several entities within the system under test.

Example 1: catch

MyPort2_PCO.check(catch(S_MyProc, tr_MyTemplate(5, v_MyVar)));

The operation is used to check whether there is an exception waiting to be caught at the port MyPort2_PCO. The signature S_MyProc defines the exception. The check operation is successful only then, when the exception matches the criteria described by the template tr_MyTemplate.

Example 2:getcall

MyPort2_PCO.check(getcall(S_MyProc:{5, MyVar}) from v_MyPartner);

The operation is used to check whether there is a procedure call waiting at the port MyPort2_PCO. The signature S_MyProc defines in-line the procedure parameters. The check operation is successful only then, when the exception matches the criteria described in the in-line signature and comes from the communication partner pointed out by the variable v_MyPartner.

Example 3: getreply

MyPort2_PCO.check(getreply(S_MyProc1:{?, v_MyVar} value *) -> value vl_MyReturnValue param(pl_MyPar1,-));

The operation is used to check whether there is a response waiting at the port MyPort2_PCO. The signature S_MyProc1 defines in-line the accepted response parameters (the first one is don't care, the second one must match the value contained in v_MyVar). The check operation is successful only then, when the exception matches the criteria described in the in-line signature (the returned value does not matter) .The returned value is saved in the variable v_MyReturnValue.

Example 4: receive

any port.check(receive(5));

The operation is used to check whether there is a message waiting at no matter which port. The check operation is successful only then, when the message contains the integer value five.

Example 5: checking anything

MujPort_PCO.check;

Checks whether anything waits for processing in the port queue at MujPort_PCO.

Example 6: checking anything on any port

any port.check (from v_MyPartner);

Checks whether anything from v_MyPartner waits for processing in any port queue.

Example 7: checking anything on any port and saving the sender

any port.check (-> sender v_MyNewPartner);

Checks whether anything waits for processing in any port queue. The address of the sender is saved in the variable v_MyNewPartner.

BNF definition of check