Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Advanced TTCN-3 usage: The secret life of shorthand notations(Or the timer that accepts messages from the network)
Advanced TTCN-3 usage: The secret life of shorthand notations [message #1737142] Wed, 06 July 2016 06:38 Go to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 60
Registered: July 2015
Member
Shorthand notations are used in TTCN-3 to make testers life easier, and the code more readable ... but sometimes using them can create hard to solve maintenance problems.

For example, if we have a function that send a text message
// send a character string
private function f_charstringSender( )
runs on altstepExample_CT
{
  portname_PT.send( "akarmi" );
}

What does the following piece of code do ? :
  vl_ptc.start( f_charstringSender() );

  timer TL_timer;
  TL_timer.start(60.0);
  TL_timer.timeout;


The answer might seem simple.
We start start a function on a component, which will send out a text message.
At the same time the test waits for 60 seconds before continuing.

But there is a trick.
Lets add an other simple function to receive the message
private altstep as_charstringHandler()
runs on altstepExample_CT
{
  var charstring vl_temp;
  
  [] portname_PT.receive(charstring: *) -> value vl_temp {
    action("charstring received");
  }
}

And activate it before the timer
var default vl_default := activate(as_charstringHandler());


Without changing the code with the timer, we have seriously altered its behaviour.
Instead of waiting for 60 seconds the timer will "expire" immediately.
What might be the reason for this?

In TTCN-3 there are several statements (including the timer.timout) which are actually only a shorthand notation for an altstep.
So our TL_timer.timeout statement is actually
alt {
  [] TL_timer.timeout;
}

As we have also activated an alt statement for receiving a text message, according to the default handling mechanism of TTCN-3 our TL_timer.timeout statement will actually behave as if it was written something like this:
alt {
  [] TL_timer.timeout;
  [] portname_PT.receive(charstring: *) ....
}


By activating an altstep for the component the test is running on, we enabled the timer to also handle messages comming from the network.

To sum up when using shorthand notations in your tests be aware that:
- they might look simple and innocent
- but might actually do whatever
- based on the altsteps that can be hard to identify from the code as they might be activate in the runtime based on dynamic criteria
- and this change can happen after you have tested and delivered your code. If you have these shorthands in your library code that is used by others in their tests, the altsteps that change the behaviour of your code might not even be present anywhere in your code. An independent library used in the same test as your, can activate them without knowing about your.
Re: Advanced TTCN-3 usage: The secret life of shorthand notations [message #1737453 is a reply to message #1737142] Fri, 08 July 2016 11:46 Go to previous message
Gustavo Gonnet is currently offline Gustavo GonnetFriend
Messages: 36
Registered: October 2015
Location: Montreal, Quebec, Canada
Member
oh wow - I wasn't aware of this and I agree with you that troubleshooting an issue like this will be really hard!
thanks
Gustavo.
Previous Topic:Advanced TTCN-3 usage: busy wait vs. non-busy wait in altsteps
Next Topic:Simple test case with CoAP
Goto Forum:
  


Current Time: Wed Apr 24 16:34:42 GMT 2024

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

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

Back to the top