From 0b35f9583164e734f003772e0bad317fed15b535 Mon Sep 17 00:00:00 2001 From: caremoli Date: Thu, 17 Jan 2008 09:44:46 +0000 Subject: [PATCH] CCAR: minor modifications to run NamingService tests under valgrind --- bin/orbmodule.py | 2 +- bin/server.py | 4 ++-- src/NamingService/SALOME_NamingService.cxx | 2 +- src/NamingService/Test/NamingServiceTest.cxx | 9 ++++++++- src/NamingService/Test/TestNamingService.py | 2 ++ src/SALOMEDS/SALOMEDS_Server.cxx | 1 + src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 2 +- src/SALOMELocalTrace/FileTraceCollector.cxx | 1 + src/SALOMETraceCollector/SALOMETraceCollector.cxx | 1 + 9 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 7de5715c1..9f3c66324 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -35,7 +35,7 @@ class client: # Initialise the ORB self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID) # Initialise the Naming Service - self.initNS(args) + self.initNS(args or {}) # -------------------------------------------------------------------------- diff --git a/bin/server.py b/bin/server.py index 5bd61799d..98b2ef95b 100755 --- a/bin/server.py +++ b/bin/server.py @@ -15,7 +15,7 @@ class Server: self.PID=None self.CMD=[] self.ARGS=[] - if self.args['xterm']: + if self.args.get('xterm'): self.ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold'] def __init__(self,args): @@ -26,7 +26,7 @@ class Server: def run(self): global process_id myargs=self.ARGS - if self.args['xterm']: + if self.args.get('xterm'): # (Debian) send LD_LIBRARY_PATH to children shells (xterm) env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index eec18908d..3c4b7e5a2 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -1065,7 +1065,7 @@ throw(ServiceUnreachable) if (binding->binding_type == CosNaming::ncontext) { - dirList.push_back(CORBA::string_dup(bindingName[0].id)); + dirList.push_back((const char*)bindingName[0].id); } } diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index 441f4fff0..bfb70a8df 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -89,6 +89,7 @@ NSTEST::echo_ptr NSTEST_aFactory_i::createInstance() NSTEST_echo_i * anEcho = new NSTEST_echo_i(_num); _num++; NSTEST::echo_var anEchoRef = anEcho->_this(); + anEcho->_remove_ref(); return anEchoRef._retn(); } @@ -149,6 +150,7 @@ NamingServiceTest::setUp() _myFactoryId = _root_poa->activate_object(_myFactory); _factoryRef = _myFactory->_this(); _pman->activate(); + _myFactory->_remove_ref(); } @@ -182,6 +184,7 @@ NamingServiceTest::testConstructorDefault() char *root = NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); + delete [] root; CPPUNIT_ASSERT(!CORBA::is_nil(obj)); CosNaming::NamingContext_var rootContext = @@ -202,6 +205,7 @@ NamingServiceTest::testConstructorOrb() char *root = NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); CPPUNIT_ASSERT(!CORBA::is_nil(obj)); + delete [] root; CosNaming::NamingContext_var rootContext = CosNaming::NamingContext::_narrow(obj); @@ -1027,7 +1031,9 @@ NamingServiceTest::testCurrentDirectory() CPPUNIT_ASSERT(ret); _NS.Change_Directory(path.c_str()); - string curdir = _NS.Current_Directory(); + char* acurdir = _NS.Current_Directory(); + string curdir = acurdir; + free(acurdir); CPPUNIT_ASSERT(curdir == path); } @@ -1204,6 +1210,7 @@ NamingServiceTest::testGetIorAddr() { char *root = _NS.getIORaddr(); CORBA::Object_var obj = _orb->string_to_object(root); + delete [] root; CPPUNIT_ASSERT(!CORBA::is_nil(obj)); } diff --git a/src/NamingService/Test/TestNamingService.py b/src/NamingService/Test/TestNamingService.py index f41e7689d..5c3a8e712 100644 --- a/src/NamingService/Test/TestNamingService.py +++ b/src/NamingService/Test/TestNamingService.py @@ -47,6 +47,8 @@ clt.waitLogger("Logger") # execute Unit Test command = ['TestNamingService'] +valgrind = ['valgrind','--leak-check=full'] +#command=valgrind+command #to check memory leaks ret = os.spawnvp(os.P_WAIT, command[0], command) # kill Test process diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index b2d2dd913..8ecce2d4b 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -161,6 +161,7 @@ int main(int argc, char** argv) // ready to accept requests. PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); myStudyManager_i->register_name("/myStudyManager"); + myStudyManager_i->_remove_ref(); // Obtain a POAManager, and tell the POA to start accepting // requests on its objects. diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 41118c5db..a7ec9b17e 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -54,7 +54,7 @@ class Standard_EXPORT SALOMEDS_StudyManager_i: public POA_SALOMEDS::StudyManager { private: - CORBA::ORB_ptr _orb; + CORBA::ORB_var _orb; PortableServer::POA_var _poa; SALOMEDSImpl_StudyManager* _impl; SALOME_NamingService* _name_service; diff --git a/src/SALOMELocalTrace/FileTraceCollector.cxx b/src/SALOMELocalTrace/FileTraceCollector.cxx index f76e18ef6..d64f5eafb 100644 --- a/src/SALOMELocalTrace/FileTraceCollector.cxx +++ b/src/SALOMELocalTrace/FileTraceCollector.cxx @@ -182,6 +182,7 @@ FileTraceCollector:: ~FileTraceCollector() int ret = pthread_join(*_threadId, NULL); if (ret) cerr << "error close FileTraceCollector : "<< ret << endl; else DEVTRACE("FileTraceCollector destruction OK"); + delete _threadId; _threadId = 0; _threadToClose = 0; } diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index 408c56d87..73163eea4 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -188,6 +188,7 @@ SALOMETraceCollector:: ~SALOMETraceCollector() int ret = pthread_join(*_threadId, NULL); if (ret) cerr << "error close SALOMETraceCollector : "<< ret << endl; else DEVTRACE("SALOMETraceCollector destruction OK"); + delete _threadId; _threadId = 0; _threadToClose = 0; } -- 2.39.2