Open mmajdoubi opened 9 years ago
Hello, I cannot reproduce this with Perl . This is my code in the first Perl test:
print "\nSetting some globals...\n";
set_global("/TC1/1", "some string");
set_global("/TC1/2", 9999);
$g0 = get_global("/TC1/1");
print "Getting some global 1 = $g0 ...\n";
$g0 = get_global("/TC1/2");
print "Getting some global 2 = $g0 ...\n";
And this in the second test:
print "Getting globals from previous glob test.\n";
$g0 = get_global("/TC1/1");
print "Getting some global 1 = $g0\n";
$g0 = get_global("/TC1/2");
print "Getting some global 2 = $g0\n";
The output for first test:
~ Perl ~ Compiling Inline::Python ~
Starting test test_globals.plx ...
Setting some globals...
Getting some global 1 = some string ...
Getting some global 2 = 9999 ...
~ Perl returned code `0` ~
The output for second test:
~ Perl ~ Compiling Inline::Python ~
Starting test test_globals_new.plx ...
Getting globals from previous glob test.
Getting some global 1 = some string
Getting some global 2 = 9999
~ Perl returned code `0` ~
The globals are kept from one Perl test to another. You could also use then from/ between Python, Perl and TCL because it's the same shared memory, as long as you use numbers and strings.
Hi, I see this is very Strange, I run exactly your scripts and my system was not able to set the global parameters (see below for the output). I also notice a warning in the server_log:
15-01-05 14:21:49 INFO CeProject.py: 2799: send_mail Preparing e-mail... Server smtp.gmail.com:587
, user **@gmail.com
, from **
, to `... 15-01-05 14:21:50 ERROR CeProject.py: 2905: send_mail SMTP: Cannot send e-mail for user
user! 15-01-05 14:22:30 INFO CeProject.py: 643: reset_project Project: Reload user operation took
0.0500seconds. 15-01-05 14:22:30 INFO CeProject.py: 2114: set_exec_status_all Status changed for
user ['mohamedm-virtual-machine_EP-1001']- running. 15-01-05 14:22:33 WARNING CeConfigs.py: 148: get_global_variable Global Variable: Invalid variable path
TC1/1, for user
user! 15-01-05 14:22:33 WARNING CeConfigs.py: 148: get_global_variable Global Variable: Invalid variable path
TC1/2, for user
user! 15-01-05 14:22:35 INFO CeProject.py: 1803: set_exec_status Project: All processes stopped for user
user`! General user status changed to STOP.
START filename: 1001:/home/user/twister/demo/testsuite-perl/test-set_globals.plx
>>>
~ Perl ~ Compiling Inline::Python ~
Setting some globals... Getting some global 1 = some string ... Getting some global 2 = 9999 ...
~ Perl returned code 0
~
File /home/user/twister/demo/testsuite-perl/test-set_globals.plx
returned 0
. <<<
Test statistics: Start time 2015-01-05 14:22:31 -- End time 2015-01-05 14:22:32 -- 1.20 sec.
END filename: 1001:/home/user/twister/demo/testsuite-perl/test-set_globals.plx
>>>
START filename: 1002:/home/user/twister/demo/testsuite-perl/test-get_globals.plx
>>>
~ Perl ~ Compiling Inline::Python ~
Getting globals from previous glob test. Getting some global 1 = 0 Getting some global 2 = 0
~ Perl returned code 0
~
File /home/user/twister/demo/testsuite-perl/test-get_globals.plx
returned 0
. <<<
Test statistics: Start time 2015-01-05 14:22:33 -- End time 2015-01-05 14:22:34 -- 0.97 sec.
END filename: 1002:/home/user/twister/demo/testsuite-perl/test-get_globals.plx
>>>
Any other idea? Should I reinstall Twister application ?
Hi, I don't think you need to reinstall. The CeConfigs.py file hasn't changed for some time so it's up to date. In the applet > configuration > global parameters, do you have the TC1 folder ? In order for the test to work, you need the "TC1" globals folder:
Maybe this is the problem ?
I reinstall twister completely but it's still not working. see my configuration below:
user@mohamedm-virtual-machine:~/twister/demo/testsuite-perl$ cat test_set_globals.plx
#!/usr/bin/perl
print "setting globals .\n";
set_global("/TC1/1",1111);
set_global("/TC1/2",2222);
$g0 = get_global("/TC1/1");
print "Getting some global 1 = $g0\n";
$g0 = get_global("/TC1/2");
print "Getting some global 2 = $g0\n";
user@mohamedm-virtual-machine:~/twister/demo/testsuite-perl$ cat test_get_globals.plx
#!/usr/bin/perl
print "getting globals from previous glob test.\n";
$g0 = get_global("/TC1/1");
print "Getting some global 1 = $g0\n";
$g0 = get_global("/TC1/2");
print "Getting some global 2 = $g0\n";
user@mohamedm-virtual-machine:~/twister/config/projects$ cat FCN.xml
<Root>
<stoponfail>false</stoponfail>
<PrePostMandatory>false</PrePostMandatory>
<DownloadLibraries>flat</DownloadLibraries>
<ScriptPre/>
<ClearCaseView/>
<libraries/>
<ScriptPost/>
<dbautosave>null</dbautosave>
<tcdelay/>
<TestSuite>
<tsName>Suite_1</tsName>
<Repeat>1</Repeat>
<PanicDetect>false</PanicDetect>
<Dependency/>
<ID>f2e74285-fec4-4577-b8f6-a6ac5a7c4ad4</ID>
<SutName>SUT_1(user)</SutName>
<EpId>mohamedm-virtual-machine_EP-1001</EpId>
<UserDefined>
<propName>Run_Number</propName>
<propValue>2</propValue>
</UserDefined>
<TestCase>
<tcName>/home/user/twister/demo/testsuite-perl/test_set_globals.plx</tcName>
<Repeat>1</Repeat>
<ID>da7af0af-cba0-48ff-9f1d-1d716aaf4795</ID>
<Dependency/>
<ConfigFiles/>
<Property>
<propName>Runnable</propName>
<propValue>true</propValue>
</Property>
<Property>
<propName>Running</propName>
<propValue>true</propValue>
</Property>
</TestCase>
<TestCase>
<tcName>/home/user/twister/demo/testsuite-perl/test_get_globals.plx</tcName>
<Repeat>1</Repeat>
<ID>7b7aa390-54f1-485f-9b59-8399c2bd2c08</ID>
<Dependency/>
<ConfigFiles/>
<Property>
<propName>Runnable</propName>
<propValue>true</propValue>
</Property>
<Property>
<propName>Running</propName>
<propValue>true</propValue>
</Property>
</TestCase>
</TestSuite>
</Root>
we do expect value 1111 and 2222 which are set by the previous testcase, unfortunately this not the case :(
any other idea, may is this related be the inline::python version? is there any debug command available for further troubleshooting, this is very strange
thanks in advance
There must be some difference between my case and your case. Could you please send me you twister project file(s)
Thanks
I did some troubleshootingl the get_global method in TscCommonLib (method is only applicable to Perl scripts) is not hitting the right part of code. that is why I get the configured global_var in stead of the one that is stored in memory.
I assume that the condition (if var in cls.global_vars) should be TRUE if a global_var is stored in memory? is there any way how to check if the globals variables are stored in memory?
/opt/twister/lib/TscCommonLib.py
@classmethod
def get_global(cls, var):
"""
Function to get variables saved from Test files.
The same data must be used, both in Testcase and derived Libraries.
"""
if var in cls.global_vars:
return cls.global_vars[var]
#Else:
ce = cls._ce_proxy()
return ce.get_global_variable(var)
@classmethod
def set_global(cls, var, value):
"""
Function to keep variables sent from Test files.
The same data must be used, both in Testcase and derived Libraries.
"""
try:
marshal.dumps(value)
cls._ce_proxy()
return cls.ce_proxy.set_global_variable(var, value)
except Exception:
cls.global_vars[var] = value
return True
First of all, I wish everybody a healthy a successful 2015
When using Perl, I notice that passing global parameters between testcases does work as expected. when using python the testcases work as expected
I used the following Perl and Python testcases to validate this functionality:
/twister/demo/testsuite-perl
——————————————————————— cat test-set_globals.plx ———————————————————————
!/usr/bin/perl
$g0 = get_global("/TC/1"); print "#######value before set#######get_global value fromt test-case1###### = $g0 ...\n"; set_global('/TC/1', "11"); $g0 = get_global("/TC/1"); print "########value after set#######get_global value fromt test-case1###### = $g0 ...\n"; exit($STATUS_PASS);
——————————————————————— cat test-get_globals.plx ———————————————————————
!/usr/bin/perl
$g0 = get_global("/TC/1"); print "##############get_global value fromt test-case2###### = $g0 ...\n";
/twister/demo/testsuite-python
——————————————————————— cat test-set-globals.py ———————————————————————
Print Level-1 / global1 param
global1 = get_global('/TC/1') print '#########value before set#########python get_global-test value:', global1, '\n' set_global('/TC/1', 11) global1 = get_global('/TC/1') print '#########value after set#########python get_global-test value:', global1, '\n' _RESULT = 'pass'
——————————————————————— cat test-get-globals.py ———————————————————————
Print Level-1 / global1 param
global1 = get_global('/TC/1') print '##################python get_global-test value:', global1, '\n' _RESULT = 'pass'
The result of both scripts are listed below
Could you please check why passing global parameters does take effect when using Perl?
Thanks in advance