Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Using the address type in Titan
Using the address type in Titan [message #1753292] Fri, 03 February 2017 11:10
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 756
Registered: January 2015
Senior Member
Dear all,

Address type is yet another area in Titan where implementation deviates from the standard for practical reasons.

Let's take a closer look: the address type is being used, according to the standard, to direct messages to different entities in the implementation under test (IUT). For example, one has a grid of servers and needs to address the nodes individually.
As such, the address values are primarily handled by the test port itself, which receives them from the ATS (abstract test suite) or from IUT and routes the messages accordingly.
To be able to do this , Titan test ports have to be generated accordingly.Since the majority of test ports do not need TTCN-3 addressing and in order to keep the test port
API backward compatible the support of address type is disabled by default.

The above means that they have to be marked with a specific extension "address"; based on this , a slightly different test port skeleton will be generated,
including the capability of handling address information.

For instance:

type port PortType1 message {
           inout integer;
    } with {extension "address"}
  

(from this, compiler -t filecontainingthetestportdeclaration.ttcn will generate the test port skeleton, to which some context-specific code has to be added manually for full functionality.)


Your observant reader may remember that internal test ports are marked with an extension "internal" , with the effect that Titan during compilation will understand that these ports
are for internal connections only and do not need external C++ code. Opposed to this, test ports marked with extension "address" are restricted to communicating with SUT only.
Obviously the two extensions are incompatible. Also, "internal" ports can be connected only, not mapped, and "address" ports can be mapped only, not connected.
(A port with no extension will require a generated external code, but can be connected or mapped as well as the user did not strongly stated the scope of usage)

The keywords to , from and sender will change their meaning depending on context: for a connected internal port they have to name component references:


module InternalPortConnect {

   type port PortType message {
        inout integer;
    } with {extension "internal"}
	
    type component TestCaseComp {
	 port PortType p;
    }
	
    type component DummyComp {
        port PortType p;
    }

	type record of DummyComp Dummy_components;
	
    testcase TC_internalPortConnect() runs on TestCaseComp system TestCaseComp {
		
	var Dummy_components           vc_dummy_components;


	for (var integer i := 0; i < 10; i := i + 1) {
	vc_dummy_components[i]:=DummyComp.create;

	}

	for (var integer i := 0; i < 10; i := i + 1) {
	connect(self:p,vc_dummy_components[i]:p);
	}

	p.send(1)  to vc_dummy_components[1]; // a component reference!!!
    }

    control {
        execute(TC_internalPortConnect());
    }
}


but for a mapped port with address , they will refer addresses:



 module AddressPortMap {
    type charstring address;
	
    type port PortType1 message {
             inout integer;
    } with {extension "address"}

 	
    type component TestCaseComp {
        port PortType1 p1;
    }
	
    testcase TC_AddressPortMap() runs on TestCaseComp system TestCaseComp {
		
        var address v_char := "someaddress";
        map(mtc:p1, system:p1);

        p1.send(5) to v_char; //an address !!!

        setverdict(pass);
    }

    control {
        execute(TC_AddressPortMap());
    }
} 
  


OK , so we have seen how to declare a port that supports addressing in IUT .
But how exactly the address type used should look like?




According to the standard, "The global address data type may be used if only one data type is needed. If several data types at different ports are needed for addressing SUT entities, the type
used for addressing via a port instance shall be declared in the corresponding port type definition."

Example of global address type
// Associates the type integer to the open type address
 type integer address; 


Example of port type-specific address type

type record MyAddressType { // user-defined type
 integer field1;
 boolean field2;
 }
type port MyPortType message {
 address MyAddressType; // address declaration
 inout integer;
 } 


Titan currently supports only the first style of declaration, but with a slightly different semantics:

the type associated with the type address is not global, but local to the module. If several port types with different addresses are
desired, they will have to be declared in separate modules and then imported.


 module Sem_060212_AddressingEntitiesInsideSut_002_B {

    type integer address;


    type port PortType2 message {

        inout integer;
    } with {extension "address"}
}

module Sem_060212_AddressingEntitiesInsideSut_002 {

import from Sem_060212_AddressingEntitiesInsideSut_002_B all;

    type charstring address;

    type port PortType1 message {
         inout integer;
    } with {extension "address"}


    type component TestCaseComp {
        port PortType1 p1;
        port PortType2 p2;
    }
	
    testcase TC_Sem_060212_AddressingEntitiesInsideSut_002() runs on TestCaseComp system TestCaseComp {
		
        var Sem_060212_AddressingEntitiesInsideSut_002_B.address v_int := 1;
        var address v_char := "test";
        
        map(mtc:p1, system:p1);
        map(mtc:p2, system:p2);
        
        // port 1 has charstring address
        p1.send(5) to v_char;

		// port 2 has integer address
        p2.send(5) to v_int;
 
        setverdict(pass);
    }

    control {
        execute(TC_Sem_060212_AddressingEntitiesInsideSut_002());
    }
} 



For further details , please check the Titan reference guide (search for "address" ) and ch 2.4 Support of address type of the API guide.

Please note that the code snippets published have been compiled and tested with the latest version of Titan compiled from source.
For an earlier release, results may be slightly different.This is only a sign of Titan being continuously developed.

Currently , the Titan toolbox contains only one test port that supports address , and that is the SIP test port( https://github.com/eclipse/titan.TestPorts.SIPmsg) .
In general, in the light of the flexible configuration of Titan test ports , this language feature does not weigh so heavy; however, support, though limited, exists.


Best regards
Elemer

[Updated on: Fri, 03 February 2017 11:26]

Report message to a moderator

Previous Topic:Titan GPIO test port for Raspberry Pi
Next Topic:Titan Architecture Internals: On parsing and checking ASN.1
Goto Forum:
  


Current Time: Wed Jun 20 00:30:40 GMT 2018

Powered by FUDForum. Page generated in 0.01918 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top