]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: minor modifications to run NamingService tests under valgrind
authorcaremoli <caremoli>
Thu, 17 Jan 2008 09:44:46 +0000 (09:44 +0000)
committercaremoli <caremoli>
Thu, 17 Jan 2008 09:44:46 +0000 (09:44 +0000)
bin/orbmodule.py
bin/server.py
src/NamingService/SALOME_NamingService.cxx
src/NamingService/Test/NamingServiceTest.cxx
src/NamingService/Test/TestNamingService.py
src/SALOMEDS/SALOMEDS_Server.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx
src/SALOMELocalTrace/FileTraceCollector.cxx
src/SALOMETraceCollector/SALOMETraceCollector.cxx

index 7de5715c1c6f6ed53982ca38626f5686b8679763..9f3c66324b7852108f47dfa85faaa4af3d2877e5 100755 (executable)
@@ -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 {})
 
    # --------------------------------------------------------------------------
 
index 5bd61799d0e88b0ec203bfc71b78dff9884ec1e7..98b2ef95b5e6c76b056419cecb6c7fd96f01eb55 100755 (executable)
@@ -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")]
index eec18908d931e1b4abe1764df8c72f1e29eab421..3c4b7e5a2aa2610386508d3afc86b7ec785937b2 100644 (file)
@@ -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);
         }
     }
 
index 441f4fff0641227bc3e9433f2d6b60a35186189c..bfb70a8df2df41ed61551eb5c86d478daf5fa6d2 100644 (file)
@@ -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)); 
 }
 
index f41e7689d4470709d1b5b3457994e230cf26ffcf..5c3a8e712e6871573d8237193eb6726b7b196d65 100644 (file)
@@ -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
index b2d2dd913e172c59f1aa019a8e90543e2a7a84ab..8ecce2d4b4132c3418ea03788aa61f7a29c6fce0 100644 (file)
@@ -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.
index 41118c5db6bb02f5ae3c32a5033e77d1beef4b4a..a7ec9b17e3f47080db104cae357414e8b9a3f48a 100644 (file)
@@ -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;
index f76e18ef6dd64f277c0e2dfbbd8c798e583b576c..d64f5eafb47c8d1e0c8a6ba6c4c815555ca884f4 100644 (file)
@@ -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;
        }
index 408c56d879e9ee0874966f93fdc21e0f5a66b013..73163eea427259b939ec0fd08dbe0e8f2f420545 100644 (file)
@@ -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;
        }