From: Cédric Aguerre Date: Tue, 17 Mar 2015 14:52:08 +0000 (+0100) Subject: fix some tests X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c23535da4769b90da5a72d44a182588ae932173a;p=modules%2Fkernel.git fix some tests --- diff --git a/src/KernelHelpers/KernelHelpersUseCases.cxx b/src/KernelHelpers/KernelHelpersUseCases.cxx index e9a9e4aad..84e55d54a 100644 --- a/src/KernelHelpers/KernelHelpersUseCases.cxx +++ b/src/KernelHelpers/KernelHelpersUseCases.cxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author: Guillaume Boulant (EDF/R&D) +// Author: Guillaume Boulant (EDF/R&D) #include "SALOME_KernelServices.hxx" #include "Basics_Utils.hxx" @@ -34,7 +34,7 @@ bool TEST_corba() { if ( ns == NULL ) { LOG("TEST_Corba: ns ERROR"); return false; - + } SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA(); if ( lcc == NULL ) { @@ -49,7 +49,7 @@ bool TEST_corba() { bool TEST_getLifeCycleCORBA() { Engines::EngineComponent_var component = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" ); - + Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component); char * coucou_res = engine->Coucou(123.); const char * coucou_ref = "L = 123"; diff --git a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx index 1f7c7e0e5..932af7382 100644 --- a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx +++ b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx @@ -40,7 +40,7 @@ void KernelHelpersUnitTests::setUp() // ============================================================================ /*! - * - delete + * - delete */ // ============================================================================ @@ -58,7 +58,7 @@ void KernelHelpersUnitTests::TEST_corba() CORBA::ORB_var orb = KERNEL::getORB(); CPPUNIT_ASSERT(!CORBA::is_nil(orb)); - + SALOME_NamingService * ns = KERNEL::getNamingService(); CPPUNIT_ASSERT(ns!=NULL); @@ -69,7 +69,7 @@ void KernelHelpersUnitTests::TEST_corba() void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() { Engines::EngineComponent_var component = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","SalomeTestComponent" ); - + Engines::TestComponent_var engine = Engines::TestComponent::_narrow(component); char * coucou_res = engine->Coucou(123.); const char * coucou_ref = "TestComponent_i : L = 123"; @@ -78,7 +78,20 @@ void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() { } void KernelHelpersUnitTests::TEST_getStudyManager() { - SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest"); + SALOMEDS::StudyManager_var studyManager = KERNEL::getStudyManager(); + + #ifndef ALLOW_MULTI_STUDIES + SALOMEDS::ListOfOpenStudies_var _list_open_studies = studyManager->GetOpenStudies(); + for (unsigned int ind = 0; ind < _list_open_studies->length();ind++) + { + LOG("Close study : " << _list_open_studies[ind]); + SALOMEDS::Study_var study = studyManager->GetStudyByName(_list_open_studies[0]); + if(study) + studyManager->Close(study); + } + #endif + + SALOMEDS::Study_ptr myTestStudy = studyManager->NewStudy("kerneltest"); CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy)); // One can use the study to store some general properties diff --git a/src/KernelHelpers/Test/TestKernelHelpers.py b/src/KernelHelpers/Test/TestKernelHelpers.py index e9fd1347a..915c9a9d5 100644 --- a/src/KernelHelpers/Test/TestKernelHelpers.py +++ b/src/KernelHelpers/Test/TestKernelHelpers.py @@ -22,10 +22,11 @@ # import sys, os,signal,string,commands +import subprocess import runSalome +import setenv import orbmodule import TestKiller -import setenv # get SALOME environment : @@ -45,9 +46,10 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestKernelHelpers'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) -# kill Test process +# kill Test process TestKiller.killProcess(runSalome.process_id) +TestKiller.closeSalome() exit(ret) diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx index e72429cda..b7f3d9ebf 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.hxx @@ -54,11 +54,15 @@ class LIFECYCLECORBATEST_EXPORT LifeCycleCORBATest : public CppUnit::TestFixture CPPUNIT_TEST( testFindOrLoad_Component_ParamsEmpty ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsLocalContainer ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsContainerName ); +#ifdef SALOME_TEST_REMOTE CPPUNIT_TEST( testFindOrLoad_Component_RemoteComputer ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer ); CPPUNIT_TEST( testFindOrLoad_Component_ParamsRemoteComputer2 ); +#endif CPPUNIT_TEST( testgetLocalFile_localComputer ); +#ifdef SALOME_TEST_REMOTE CPPUNIT_TEST( testgetLocalFile_remoteComputer ); +#endif // CPPUNIT_TEST( testFindOrLoad_Component_ ); // CPPUNIT_TEST( ); // CPPUNIT_TEST( ); diff --git a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py index 1d6984f20..101bff641 100644 --- a/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py +++ b/src/LifeCycleCORBA/Test/TestLifeCycleCORBA.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import setenv import orbmodule @@ -73,12 +74,13 @@ clt.waitNS("/SalomeLauncher") # execute Unit Test command = ['./TestLifeCycleCORBA'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) # kill containers created by the Container Manager import Engines launcher = clt.waitNS("/SalomeLauncher",Engines.SalomeLauncher) + launcher.Shutdown() # kill Test process @@ -86,4 +88,5 @@ launcher.Shutdown() addToKillList.killList() TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/LifeCycleCORBA_SWIG/Test/TestLifeCycleCORBA_SWIG.py b/src/LifeCycleCORBA_SWIG/Test/TestLifeCycleCORBA_SWIG.py index 0e0fc1955..45adaa1e6 100644 --- a/src/LifeCycleCORBA_SWIG/Test/TestLifeCycleCORBA_SWIG.py +++ b/src/LifeCycleCORBA_SWIG/Test/TestLifeCycleCORBA_SWIG.py @@ -27,6 +27,7 @@ # $Header$ # import sys, os,signal,string,commands +import subprocess import runSalome import setenv import orbmodule @@ -78,7 +79,7 @@ clt.waitNS("/SalomeLauncher") # execute Unit Test command = ['TestLifeCycleCORBA'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) import LifeCycleCORBA_SWIGTest import unittest @@ -95,4 +96,5 @@ launcher.Shutdown() addToKillList.killList() TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/Logger/Test/TestKiller.py b/src/Logger/Test/TestKiller.py index 780fe6e7e..ea04934ce 100644 --- a/src/Logger/Test/TestKiller.py +++ b/src/Logger/Test/TestKiller.py @@ -23,6 +23,24 @@ import sys, os,signal,string,commands +def getCurrentPort(): + fic=os.environ['OMNIORB_CONFIG'] + with open(fic,'r') as f: + line=f.readline() + port=string.split(line,':')[-1][0:4] + return port + + +def closeSalome(): + port = getCurrentPort() + try: + from PortManager import releasePort + print "### release current port:", port + releasePort(port) + except: + pass + + def killNamingService(): """ kills omniORB4 Naming Service on local machine. @@ -30,11 +48,7 @@ def killNamingService(): Works only with a single line $OMNIORB_CONFIG like InitRef = NameService=corbaname::: """ - fic=os.environ['OMNIORB_CONFIG'] - f=open(fic,'r') - line=f.readline() - f.close() - port=string.split(line,':')[-1][0:4] + port = getCurrentPort() command='ps -eo pid,command | grep "omniNames -start '+str(port)+'" | grep --invert-match grep' output_com = commands.getoutput(command) try: diff --git a/src/NamingService/Test/TestNamingService.py b/src/NamingService/Test/TestNamingService.py index fdeb07791..46096c24e 100644 --- a/src/NamingService/Test/TestNamingService.py +++ b/src/NamingService/Test/TestNamingService.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import setenv import orbmodule @@ -54,9 +55,10 @@ clt.waitLogger("Logger") command = ['./TestNamingService'] valgrind = ['valgrind','--leak-check=full'] #command=valgrind+command #to check memory leaks -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) # kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/SALOMEDS/Test/TestSALOMEDS.py b/src/SALOMEDS/Test/TestSALOMEDS.py index 90335a706..ce38430fd 100644 --- a/src/SALOMEDS/Test/TestSALOMEDS.py +++ b/src/SALOMEDS/Test/TestSALOMEDS.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import orbmodule import TestKiller @@ -45,9 +46,10 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestSALOMEDS'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) -# kill Test process +# kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py index e1795ba89..70c888c2f 100644 --- a/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py +++ b/src/SALOMEDSImpl/Test/TestSALOMEDSImpl.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import orbmodule import TestKiller @@ -45,9 +46,10 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestSALOMEDSImpl'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) -# kill Test process +# kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/SALOMELocalTrace/Test/TestSALOMELocalTrace.py b/src/SALOMELocalTrace/Test/TestSALOMELocalTrace.py index 4eb8017b4..473e241cc 100644 --- a/src/SALOMELocalTrace/Test/TestSALOMELocalTrace.py +++ b/src/SALOMELocalTrace/Test/TestSALOMELocalTrace.py @@ -21,7 +21,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import sys, os,signal,string,commands +import sys, signal,string,commands +import subprocess import runSalome import setenv @@ -34,7 +35,7 @@ setenv.set_env(args, modules_list, modules_root_dir) # execute Unit Test command = ['./TestSALOMELocalTrace'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) # no process to kill -exit(ret) \ No newline at end of file +exit(ret) diff --git a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py index f04cfb6da..345924410 100644 --- a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py +++ b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import orbmodule import TestKiller @@ -45,9 +46,9 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestSALOMETraceCollector'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) -# kill Test process +# kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +exit(ret) diff --git a/src/UnitTests/UnitTests.py b/src/UnitTests/UnitTests.py index 30bfdfc89..1ec8254a7 100644 --- a/src/UnitTests/UnitTests.py +++ b/src/UnitTests/UnitTests.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import setenv import orbmodule @@ -72,7 +73,7 @@ clt.waitNS("/SalomeLauncher") # execute Unit Test command = ['./UnitTests'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) # kill containers created by the Container Manager @@ -83,4 +84,5 @@ launcher.Shutdown() # kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret) diff --git a/src/Utils/Test/TestUtils.py b/src/Utils/Test/TestUtils.py index 3bc8f86c4..dd54a922f 100644 --- a/src/Utils/Test/TestUtils.py +++ b/src/Utils/Test/TestUtils.py @@ -22,6 +22,7 @@ # import sys, os,signal,string,commands +import subprocess import runSalome import orbmodule import TestKiller @@ -45,9 +46,10 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestUtils'] -ret = os.spawnvp(os.P_WAIT, command[0], command) +ret = subprocess.call(command) # kill Test process TestKiller.killProcess(runSalome.process_id) -exit(ret) \ No newline at end of file +TestKiller.closeSalome() +exit(ret)