Variables used in several .cfg files [message #1838799] |
Fri, 05 March 2021 03:47  |
Eclipse User |
|
|
|
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 12:45   |
Eclipse User |
|
|
|
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 } }
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03924 seconds