Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Variables used in several .cfg files
Variables used in several .cfg files [message #1838799] Fri, 05 March 2021 08:47 Go to next message
Julien Deltour is currently offline Julien DeltourFriend
Messages: 6
Registered: March 2021
Junior Member
Hello

I'm currently using Titan to generate/execute some testcases (ITS).

For each testsuite, there is a .cfg file indicating configurations (ip address, mac address, ...) and testcases to execute.

Some of configuration variables are common to all testsuite (ip address of the SUT for example) so I would like to have a commonConfig.cfg where all common value are defined, and this .cfg is imported in all other .cfg file.

for example :

SUT_dst_ip := 192.168.1.1
SUT_dst_port := 12345

I see there is the [DEFINE] section present :
Define. This section contains definitions of macros that can be used in other configuration file sections(except Include) for entry of recurring values.

but there is no example of the syntax to use to define a "global" variable. And are the variable defined in this section imported if the .cfg is indicated in the Include section ?

Thanks

Julien
Re: Variables used in several .cfg files [message #1838822 is a reply to message #1838799] Fri, 05 March 2021 17:45 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 133
Registered: December 2015
Senior Member
You can put the defined macros into a separate cfg file and import it. The "except Include" means that the macros can not be used in the [INCLUDE] section. But the cfg file with [DEFINE] section can be imported.

Example

module proba{

modulepar integer mp_i1
modulepar integer mp_i2
modulepar R_rec mp_r1
modulepar R_rec mp_r2
modulepar R_rec mp_r3

type record R_rec{
  charstring f1,
  integer f2
}
  
testcase TC1() runs on CT {
  log("mp_i1", mp_i1)
  log("mp_i2", mp_i2)
  log("mp_r1", mp_r1)
  log("mp_r2", mp_r2)
  log("mp_r3", mp_r3)
}
}


The main cfg file:
[ORDERED_INCLUDE]
"macro.cfg"
"tc.cfg"


[LOGGING]
FileMask:=LOG_ALL

[EXECUTE]
proba.TC1


The macro.cfg
[DEFINE]
SUT_dst_ip :=192.168.1.1
SUT_dst_port :=12345
DEF1 := 2
DEF2 :={ f1:= "2.2.2.2", f2:=1234}


The tc.cfg:
[MODULE_PARAMETERS]
mp_i1 := 1
mp_i2 := ${DEF1,integer}

mp_r1 := {"1.2.3.4",3333}
mp_r2:= $DEF2
mp_r3:= {f1:= $SUT_dst_ip, f2:=${SUT_dst_port,integer} }


The result:
18:37:14.648782 Module proba has the following parameters: {
mp_i1 := 1,
mp_i2 := 2, 
mp_r1 := { f1 := "1.2.3.4", f2 := 3333 },
mp_r2 := { f1 := "2.2.2.2", f2 := 1234 },
mp_r3 := { f1 := "192.168.1.1", f2 := 12345 } }
Re: Variables used in several .cfg files [message #1839041 is a reply to message #1838822] Thu, 11 March 2021 16:31 Go to previous messageGo to next message
Julien Deltour is currently offline Julien DeltourFriend
Messages: 6
Registered: March 2021
Junior Member
Thanks for this answer
Re: Variables used in several .cfg files [message #1841287 is a reply to message #1839041] Tue, 11 May 2021 07:29 Go to previous messageGo to next message
Julien Deltour is currently offline Julien DeltourFriend
Messages: 6
Registered: March 2021
Junior Member
Hello, I try to use what you propose, but I have mistake.

I have one file globalConfig.cfg :

[DEFINE]
SUT_IP := "192.168.1.24"
SUT_PORT :=12345


And one other file :

[ORDERED_INCLUDE]
"../globalConfig.cfg"
 
.......

system.utPort.params := "UT_CAM/UDP(dst_ip=SUT_IP,dst_port=$(SUT_PORT))"


And in this setup, I have errors. If I replace SUT_IP in my second file by the ip in hard 192.168.1.24, it works perfectly.

Is the syntax correct for using DEFINE ? I try SUT_IP or $SUT_IP but nothing works.
Re: Variables used in several .cfg files [message #1841290 is a reply to message #1841287] Tue, 11 May 2021 08:24 Go to previous messageGo to next message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 133
Registered: December 2015
Senior Member
The macros are not resolved inside the strings.
Try:
system.utPort.params :=  "UT_CAM/UDP(dst_ip=" & $SUT_IP & ",dst_port=12345)"
Re: Variables used in several .cfg files [message #1841291 is a reply to message #1841290] Tue, 11 May 2021 08:58 Go to previous message
Julien Deltour is currently offline Julien DeltourFriend
Messages: 6
Registered: March 2021
Junior Member
Thanks Gabor, it works.
Previous Topic:Can not add Titan in Eclipse
Next Topic:ANTLR version will be upgraded for Eclipse Titan Executor plugin
Goto Forum:
  


Current Time: Thu Apr 25 17:59:05 GMT 2024

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

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

Back to the top