Home » Eclipse Projects » Eclipse Titan » Default Parameters in Template Bug ?(When using function in template for default parameters, the function is not recall.)
Default Parameters in Template Bug ? [message #1777997] |
Thu, 07 December 2017 14:07 |
Emilien Bourdy Messages: 5 Registered: December 2017 |
Junior Member |
|
|
Hi everyone !
I'm integrating ITS tests used by ETSI with TTWB in TITAN. But to my dismay, for DENM, default parameter for timestamp in the templates use a function to get current time.
But when I execute the tests, this function is called at the begining, before all initialize, and they are not recall, so after two tests, I have 40 s of difference between my time and tester time (I precise that they are on the same machine).
So, my question is : is it a Titan bug, or will it stay like that and change all call to these template to use the function to initialize the parameter.
It's simpler with example : I'm have to change
m_denm(
m_denmMgmtConTermination(
m_tsActionId,
-,
c_transmissionInterval * 4 / 1000,
c_transmissionInterval
),
v_situation,
m_denmLocation_zeroDelta
)
to
m_denm(
m_denmMgmtCon(
m_tsActionId,
-,
c_transmissionInterval * 4 / 1000,
c_transmissionInterval,
f_getCurrentTime(),
f_getCurrentTime()
),
v_situation,
m_denmLocation_zeroDelta
)
because the template is
template (value) ManagementContainer m_denmMgmtCon(
template (value) ActionID p_actionID,
template (value) StationType p_stationType := f_getTsStationType(),
template (value) ValidityDuration p_validityDuration := defaultValidity,
template (omit) TransmissionInterval p_transmissionInterval := omit,
template (value) TimestampIts p_detectionTime := f_getCurrentTime(),
template (value) TimestampIts p_referenceTime := f_getCurrentTime()
) := {
actionID := p_actionID,
detectionTime := p_detectionTime,
referenceTime := p_referenceTime,
termination := omit,
eventPosition := m_tsPosition,
relevanceDistance := lessThan50m,
relevanceTrafficDirection := allTrafficDirections,
validityDuration := p_validityDuration,
transmissionInterval := p_transmissionInterval,
stationType := p_stationType
}
I hope I was clear, and you can answer to my question.
Best regards
E. Bourdy
|
|
|
Re: Default Parameters in Template Bug ? [message #1778030 is a reply to message #1777997] |
Fri, 08 December 2017 11:10 |
|
Hi Emilien,
OK , this is what I understood so far:
If for the template m_denmMgmtCon one relies on the default value of the parameter say p_referenceTime (which is the return value of f_getCurrentTime() ) and invokes this parameter with "-",
like here :
m_denmMgmtConTermination(
m_tsActionId,
-,
c_transmissionInterval * 4 / 1000,
c_transmissionInterval,
-, //default:= f_getCurrentTime()
-, //default:=f_getCurrentTime()
isCancellation
)
then the value of the parameter stays the same
(Mind that I have used "-" which does not appear in your example; please confirm that this is an oversight from your part)
If instead of the "-" we use the function as parameter, as in:
m_denmMgmtConTermination(
m_tsActionId,
-,
c_transmissionInterval * 4 / 1000,
c_transmissionInterval,
f_getCurrentTime(),
f_getCurrentTime(),
isCancellation
)
then the parameter value changes accordingly at every new invokation.
Please confirm that I understood correctly;
I have verified it and this is indeed the current behaviour.
I can't tell yet you whether this is a fault or not ; we have to look into the standard carefully;
I will come back to you soonest
Best regards
Elemer
[Updated on: Fri, 08 December 2017 16:02] Report message to a moderator
|
|
| |
Re: Default Parameters in Template Bug ? [message #1778253 is a reply to message #1778036] |
Tue, 12 December 2017 11:11 |
|
Hi Emilien,
Here's our conclusion:
- this is a side effect of a speed optimization:
Titan calls the function referred as default parameter at the beginning of execution
and then reuses the return value to save time;
This works well for deterministic functions , but causes problems with non-deterministic ones , as those that depend on time.
What we can offer as a solution is to implement the standard behaviour in runtime 2 (function test runtime) ,
but keeping the current behaviour in the default runtime (runtime 1 , load test runtime) .
Practically this means that users of runtime 1 will have to continue to use direct function references as parameters as you did.
Users of runtime 2 will have the choice of using the standard notation for default "-".
I don't have an ETA for this modification, most likely it will be added during January.
BR
Elemer
|
|
| |
Re: Default Parameters in Template Bug ? [message #1778258 is a reply to message #1778254] |
Tue, 12 December 2017 11:38 |
|
Hi Emilien,
yes, we know about the @deterministic, but it poses two problems;
-first , the majority of functions are deterministic , so it would be easier to mark those which aren't (with @nondeterministic maybe?)
-secondly it would cause legacy problems, as in our existing test suites with speed requirements the functions are not marked with @deterministic so the above modification
would cause issues
However, we will be evaluating the different options
BR
Elemer
|
|
|
Re: Default Parameters in Template Bug ? [message #1780101 is a reply to message #1778258] |
Wed, 17 January 2018 12:03 |
|
Hi Emilien,
we have implemented the correction in Runtime 2 , as discussed above,
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=529019
We will not release a binary at this time, if you need this modification please compile from source.
You can migrate your project to Runtime 2 with a loss of speed of execution you will probably not notice.
To change your project you will have to do the following modifications in your Makefile (after running a make clean first of course):
1. add -DTITAN_RUNTIME_2 to CPPFLAGS:
# Flags for the C++ preprocessor (and makedepend as well):
CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)/include -DTITAN_RUNTIME_2
2. add -R to compiler flags:
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -L ..other flags.. -R
3.change TTCN3_LIB to ttcn3-rt2 or ttcn3-rt2-parallel (from ttcn3 or ttcn3-parallel)
# Execution mode: (either ttcn3 or ttcn3-parallel)
TTCN3_LIB = ttcn3-rt2-parallel
Best regards
Elemer
|
|
|
Goto Forum:
Current Time: Thu Sep 26 09:40:58 GMT 2024
Powered by FUDForum. Page generated in 0.04361 seconds
|