Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Question regarding mapping of components and parameters
Question regarding mapping of components and parameters [message #1831224] Fri, 14 August 2020 07:48 Go to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Hello all,

I have the following problem implementing my test cases:
I want to map my communication port in some sub function called by the test case, but I do not find the correct way to do it. The structure looks like this:

 
  30     testcase TC_SECC_ATB_001() runs on SEC_Tester system SystemSEC {                                                                                                                                                                    
   31                                                                                                                                                                                                                                         
   32         var verdicttype preConVerdict;                                                                                                                                                                                                  
   33                                                                                                                                                                                                                                         
   34         // -------------- Pre Conditions-------------------------------------------------------                                                                                                                                         
   35         preConVerdict := f_SEC_CMN_Setup_001();                                                                                                                                                                                         
   36                                                                                                                                                                                                                                         
   37         //-------------- Test behavior---------------------------------------------------------                                                                                                                                         
   38         if(preConVerdict == pass) {                                                                                                                                                                                                     
   39             f_SEC_CMN_001();                                                                                                                                                                                                            
   40         }                                                                                                                                                                                                                               
   41         else {                                                                                                                                                                                                                          
   42             log("PreCondition was unsuccessful.");                                                                                                                                                                                      
   43         }                                                                                                                                                                                                                               
   44                                                                                                                                                                                                                                         
   45         //------------- Post Conditions--------------------------------------------------------                                                                                                                                         
   46         tc_CommunicationSetup_Timer.stop;                                                                                                                                                                                               
   47     }                                                   


I want to map the port inside the function f_SEC_CMN_Setup_001(). When I try to do it with the system keyword, the compiler alerts "Cannot determine system component in `map' operation with `param' clause".
My workaround for that was to add the "systemSEC" clause and to provide system as parameter of type SystemSEC to the function and then map the port to that. This works, but the map parameters never make it to the port. user_map gets called, but without params. If I map the port directly to system in the testcase, everything works as intended.

I would be glad to receive some hints on how to do that. Maybe I'm also misunderstanding something fundamental about components and ports since TTCN is new to me.

Thank you and best regards,
Moritz
Re: Question regarding mapping of components and parameters [message #1831247 is a reply to message #1831224] Sat, 15 August 2020 06:56 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
How the structure of the f_SEC_CMN_Setup_001 looks like?

According to the standard, if the map is used with param, the type of the system component should be known at the compile time. So either the map with param should be called from the testcase directly or from a function with system clause.

The function should looks like:
function f_SEC_CMN_Setup_001() runs on SEC_Tester system SystemSEC return ... {

map(<ct>:<pt>,system:<pt>) param (...)

}

Re: Question regarding mapping of components and parameters [message #1831250 is a reply to message #1831247] Sat, 15 August 2020 07:44 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Hey Gábor, thank you for the reponse.
I tried that too. The function header looks like this:

 function f_SEC_CMN_SETUP_001() runs on SEC_Tester system SystemSEC return verdicttype


And the mapping operation:
map(mtc:pt_TCP_TLS_Test_Port, system:pt_TCP_TLS_Test_Port)                                                                                                                                                      
param(vc_connection_parameters);


The compiler throws the error "Cannot determine system component in `map' operation with `param' clause"

BR,
Moritz
Re: Question regarding mapping of components and parameters [message #1831251 is a reply to message #1831250] Sat, 15 August 2020 07:56 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
You found a bug in the TITAN.

If the function has a return type, the compiler errors out.

try to use out parameter instead of return:

function f_SEC_CMN_SETUP_001(out verdicttype pl_ret) runs on SEC_Tester system SystemSEC
Re: Question regarding mapping of components and parameters [message #1831253 is a reply to message #1831251] Sat, 15 August 2020 14:09 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
The bugreport:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=566094
Re: Question regarding mapping of components and parameters [message #1831279 is a reply to message #1831253] Sun, 16 August 2020 09:50 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Thanks for your effort! This makes it possible to compile.

But I still don't get any parameters mapped to the test port if I do the map inside f_SEC_CMN_SETUP_001. The map operation still looks like this:

map(mtc:pt_TCP_TLS_Test_Port, system:pt_TCP_TLS_Test_Port)                                                                                                                                                      
param(vc_connection_parameters);


Doing it directly in the test case works as expected.

BR,
Moritz

[Updated on: Sun, 16 August 2020 09:54]

Report message to a moderator

Re: Question regarding mapping of components and parameters [message #1831282 is a reply to message #1831279] Sun, 16 August 2020 13:17 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
I tried to test it, but the map param works from function for me.

See the small attached example. Can you try it?

You can check the generated code also.

Code generated for map without param:

Map_Params tmp_4(0);
TTCN_Runtime::map_port(self, CT_component_p1.get_name(), SYSTEM_COMPREF, "p2", tmp_4);

Code generated for map with param, see the set_param call:
Map_Params tmp_2(1);
tmp_2.set_param(0, ttcn_to_string(INTEGER(23)));
TTCN_Runtime::map_port(self, CT_component_p1.get_name(), SYSTEM_COMPREF, CTS_component_p2.get_name(), tmp_2);
Re: Question regarding mapping of components and parameters [message #1831311 is a reply to message #1831282] Mon, 17 August 2020 09:43 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Hey,
I am trying to reproduce the error through extending your example without success yet.

But looking at the generated code there definitely seems to be an issue:

This is the line in the PreConditions_SEC.ttcn file:

25         map(mtc:pt_TCP_TLS_Test_Port, system:pt_TCP_TLS_Test_Port) param(vc_tcp_tls_parameter);


And this is the resulting line in the resulting PreConditions_SEC.cc file:

102 current_location.update_lineno(25);                                                                                                                                                                                                      103 /* PreConditions_SEC.ttcn, line 25 */                                                                                                                                                                                                  
104 {                                                                                                                                                                                                                                       
105 Map_Params tmp_2(0);                                                                                                                                                                                                                    
106 TTCN_Runtime::map_port(MTC_COMPREF, "pt_TCP_TLS_Test_Port", SYSTEM_COMPREF, ComponentsAndPorts::SystemSEC_component_pt__TCP__TLS__Test__Port.get_name(), tmp_2);                                                     
107 }                       


I'm continuing to try to provide an example project showing this behavior since company policy currently disallows sharing the whole project publicly.

BR,
Moritz
Re: Question regarding mapping of components and parameters [message #1831314 is a reply to message #1831311] Mon, 17 August 2020 09:57 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Moritz,

a quick question: which actual test port do you intend to use?
The Titan test ports we have published so far have no support for "map param" so parameters will not propagate to the test port.
They are configured either statically, via the config file, or dynamically , via purposeful messages sent to the test port.

Best regards
Elemer


Re: Question regarding mapping of components and parameters [message #1831316 is a reply to message #1831314] Mon, 17 August 2020 10:04 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Hey Elemer,
thank you for chiming in. This is a self-written test port which uses AbstractSocket and is prepared to receive parameters through the user_map function. When I map the parameters in the test case directly, everything works fine.

BR,
Moritz
Re: Question regarding mapping of components and parameters [message #1831317 is a reply to message #1831316] Mon, 17 August 2020 10:26 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Moritz,

that makes sense. I wish you good luck with your project.


Best regards
Elemer
Re: Question regarding mapping of components and parameters [message #1831318 is a reply to message #1831316] Mon, 17 August 2020 10:28 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Meanwhile I found the difference between our two approaches: I am mapping from the mtc component and Gábor is mapping from the self component.
I would have expected those to be identical because but this may be the point where I made the mistake.
So my behavior is reproducable through exchanging those two component references in Gábors example.

BR,
Moritz
Re: Question regarding mapping of components and parameters [message #1831319 is a reply to message #1831318] Mon, 17 August 2020 10:30 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Moritz,

that's useful; we will look into it, and if there's an error, we'll do our best to fix it.


Best regards
Elemer
Re: Question regarding mapping of components and parameters [message #1831320 is a reply to message #1831319] Mon, 17 August 2020 10:56 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
Yes, I can reproduce the bug with my example code, just replacing self with mtc.

Re: Question regarding mapping of components and parameters [message #1831321 is a reply to message #1831319] Mon, 17 August 2020 11:00 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
Updated the bug report.

Sorry for the inconvenience, this is a new feature in the TITAN and probably you're the first one who use.
Re: Question regarding mapping of components and parameters [message #1831322 is a reply to message #1831321] Mon, 17 August 2020 11:06 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
No problem, thank you for your work on this project!
Re: Question regarding mapping of components and parameters [message #1838676 is a reply to message #1831322] Wed, 03 March 2021 13:21 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
Hey all, sorry, to reopen this issue. I am now returning to this project.

In the referenced bug ticket the two bugs are reported as closed. My ttcn_compiler version is 7.2.pl0 and the bug seems to be still there (and extended).

I am now using the parallel runtime. The TTCN code is the following:

log("Going to pass ", vc_tcp_tls_parameter);
map(self:pt_TCP_TLS_SEC_Port, system:pt_TCP_TLS_SEC_Port) 
param (vc_tcp_tls_parameter);


and the generated C code is the following:

Map_Params tmp_6(0);                                                                                                                                                                                                                                                                  
TTCN_Runtime::map_port(self, ComponentsAndPorts::SEC__Tester_component_pt__TCP__TLS__SEC__Port.get_name(), SYSTEM_COMPREF, ComponentsAndPorts::SystemSEC_component_pt__TCP__TLS__SEC__Port.get_name(), tmp_6);                                                                                                                            


I am not able to receive the parameter in the port, despite using the self (or the mtc, too) component.

BR,
Moritz

[Updated on: Wed, 03 March 2021 13:23]

Report message to a moderator

Re: Question regarding mapping of components and parameters [message #1838680 is a reply to message #1838676] Wed, 03 March 2021 13:53 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
I'm trying to reproduce the fault, but I can't provoke it. Can you try to reproduce with the map_param.tgz attached above?
Re: Question regarding mapping of components and parameters [message #1838893 is a reply to message #1838680] Mon, 08 March 2021 11:43 Go to previous messageGo to next message
Moritz Klass is currently offline Moritz KlassFriend
Messages: 22
Registered: August 2020
Junior Member
I am able to reproduce it through removing the map parameter in the port declaration. I'm not sure whether map parameters have to be announced in this way in order to be used - If yes, this may not be a bug and I may have been lucky that it worked like it did in the previous stages of my project.

Re: Question regarding mapping of components and parameters [message #1838894 is a reply to message #1838893] Mon, 08 March 2021 12:09 Go to previous message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 131
Registered: December 2015
Senior Member
Yes, according to the standard:
"The map operation provides an optional parameter list for configuration purposes. This allows to pass values needed for dynamic runtime configuration. If a parameter list is present, the actual parameters shall conform to the map param clause of the port type declaration of the system port used."
Previous Topic:RFC: Configurable warnings / errors for ttcn3_compiler
Next Topic:Experimental Titan build for Raspberry Pi
Goto Forum:
  


Current Time: Thu Mar 28 16:20:21 GMT 2024

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

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

Back to the top