]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 18 Aug 2021 14:38:10 +0000 (16:38 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 18 Aug 2021 14:38:10 +0000 (16:38 +0200)
src/NamingService/SALOME_Fake_NamingService.cxx
src/NamingService/SALOME_Fake_NamingService.hxx
src/SALOMESDS/TestSalomeSDS.py
src/SALOMESDS/TestSalomeSDSHelper0.py

index e9e19f30d489934edb247937cef95c1ffc612de8..ce5360833db8b0bc633454b205571604f479fe3b 100644 (file)
@@ -72,9 +72,32 @@ void SALOME_Fake_NamingService::Destroy_FullDirectory(const char* Path)
 
 bool SALOME_Fake_NamingService::Change_Directory(const char* Path)
 {
+  _current_dir = Path;
   return true;
 }
 
+std::vector<std::string> SALOME_Fake_NamingService::SplitDir(const std::string& fullPath)
+{
+  constexpr char SEP = '/';
+  std::vector<std::string> ret;
+  if(fullPath.empty())
+    THROW_SALOME_EXCEPTION("Empty input string");
+  if(fullPath.at(0) != SEP)
+    THROW_SALOME_EXCEPTION("input string is expected to start with " << SEP);
+  auto len = fullPath.length();
+  if( len == 1 )
+    THROW_SALOME_EXCEPTION("input string is expected to be different from " << SEP);
+  std::size_t pos = 1;
+  while(pos < len)
+  {
+    std::size_t endPos = fullPath.find_first_of(SEP,pos);
+    std::string elt(fullPath.substr(pos,endPos==std::string::npos?std::string::npos:endPos-pos));
+    ret.push_back(elt);
+    pos = endPos==std::string::npos?std::string::npos:endPos+1;
+  }
+  return ret;
+}
+
 std::vector<std::string> SALOME_Fake_NamingService::list_subdirs()
 {
   return std::vector<std::string>();
@@ -82,7 +105,20 @@ std::vector<std::string> SALOME_Fake_NamingService::list_subdirs()
 
 std::vector<std::string> SALOME_Fake_NamingService::list_directory()
 {
-  return std::vector<std::string>();
+  std::vector<std::string> ret;
+  std::vector<std::string> splitCWD(SplitDir(_current_dir));
+  auto len = _current_dir.length();
+  for(auto it : _map)
+  {
+    std::vector<std::string> splitIt(SplitDir(it.first));
+    if(splitIt.size()<=splitCWD.size())
+      continue;
+    std::vector<std::string> partSplitIt(splitIt.cbegin(),splitIt.cbegin()+splitCWD.size());
+    if(partSplitIt!=splitCWD)
+      continue;
+    ret.push_back(splitIt.at(splitCWD.size()));
+  }
+  return ret;
 }
 
 std::vector<std::string> SALOME_Fake_NamingService::list_directory_recurs()
index 295433cfaa88471bb40c2a9b51055b1860880e3d..a4a10f96b84df82af176ad5ae293b9bc2c867c3b 100644 (file)
@@ -56,9 +56,12 @@ private:
   static std::string ReprOfContainersIORS();
   static std::vector< std::pair< std::string, Engines::Container_var> > ListOfContainersInNS_NoThreadSafe();
   static void FlushLogContainersFile_NoThreadSafe();
+  static std::vector<std::string> SplitDir(const std::string& fullPath);
 private:
   static std::mutex _mutex;
   static std::map<std::string,CORBA::Object_var> _map;
   static bool _log_container_file_thread_launched;
   static std::string _log_container_file_name;
+private:
+  mutable std::string _current_dir;
 };
index d61a9e1ed3bc6f249bcfb301f9026ee693efee79..9a37b1284fadd9be8b7c553d89d44d6ddeec77cd 100644 (file)
@@ -95,7 +95,7 @@ def func_test7(scopeName,cv,cv2,cv3,sharedNum):
   
 class SalomeSDSTest(unittest.TestCase):
   
-  def tessList1(self):
+  def testList1(self):
     a=SalomeSDSClt.CreateRdExtGlobalVar([],"a","Scope0")
     self.assertEqual(a.local_copy(),[])
     a.append(5)
@@ -114,7 +114,7 @@ class SalomeSDSTest(unittest.TestCase):
     a.ptr().getMyDataScopeServer().deleteVar("a")
     pass
   
-  def tessDict1(self):
+  def testDict1(self):
     a=SalomeSDSClt.CreateRdExtGlobalVar({},"a","Scope0")
     a["ab"]=4
     self.assertEqual(a.local_copy(),{"ab":4})
@@ -135,7 +135,7 @@ class SalomeSDSTest(unittest.TestCase):
     a.ptr().getMyDataScopeServer().deleteVar("a")
     pass
 
-  def tessReadOnly1(self):
+  def testReadOnly1(self):
     a=SalomeSDSClt.CreateRdOnlyGlobalVar({"ab":4,"cd":[5,77]},"a","Scope0")
     self.assertEqual(a.local_copy(),{"ab":4,"cd":[5,77]})
     self.assertRaises(Exception,a.__getitem__,"ab")
@@ -166,13 +166,13 @@ class SalomeSDSTest(unittest.TestCase):
     #
     nbProc=8
     pool=mp.Pool(processes=nbProc)
-    from  NamingService import NamingService
+    from NamingService import NamingService
     asyncResult=pool.map_async(work,[(NamingService.IOROfNS(),i,varName,scopeName) for i in range(nbProc)])
     print("asyncResult=", asyncResult)
     self.assertEqual(asyncResult.get(),nbProc*[0]) # <- the big test is here !
     dsm.removeDataScope(scopeName)
 
-  def tessTransaction2(self):
+  def testTransaction2(self):
     scopeName="Scope1"
     varName="a"
     dsm=salome.naming_service.Resolve("/DataServerManager")
@@ -196,7 +196,7 @@ class SalomeSDSTest(unittest.TestCase):
     wk.waitFor()
     self.assertEqual(str2Obj(dss.waitForMonoThrRev(wk)),[7,8,9,10])
 
-  def tessTransaction3(self):
+  def testTransaction3(self):
     scopeName="Scope1"
     varName="a"
     dsm=salome.naming_service.Resolve("/DataServerManager")
@@ -218,7 +218,7 @@ class SalomeSDSTest(unittest.TestCase):
     dss.atomicApply([t2])
     self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'cd':[7,8,9,10]})
 
-  def tessTransaction4(self):
+  def testTransaction4(self):
     scopeName="Scope1"
     varName="a"
     dsm=salome.naming_service.Resolve("/DataServerManager")
@@ -242,7 +242,7 @@ class SalomeSDSTest(unittest.TestCase):
     dss.atomicApply([t2])
     self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})
 
-  def tessTransaction5(self):
+  def testTransaction5(self):
     """ Like testTransaction2 but without transactions. """
     scopeName="Scope1"
     varName="a"
@@ -276,7 +276,7 @@ class SalomeSDSTest(unittest.TestCase):
     keys=[str2Obj(elt) for elt in dss.getAllKeysOfVarWithTypeDict(varName)]
     self.assertEqual(set(keys),set(['ab','cd']))
 
-  def tessTransaction6(self):
+  def testTransaction6(self):
     """ Test to test RdWr global vars with transaction"""
     scopeName="Scope1"
     varName="a"
@@ -325,7 +325,7 @@ class SalomeSDSTest(unittest.TestCase):
       dsm.removeDataScope(scopeName)
     pass
 
-  def tessTransaction7(self):
+  def testTransaction7(self):
     """Like testTransaction5 but after a recovery."""
     scopeName="Scope1"
     varName="a"
@@ -349,7 +349,7 @@ class SalomeSDSTest(unittest.TestCase):
     self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
     pass
 
-  def tessTransaction8(self):
+  def testTransaction8(self):
     """ EDF 16833 and EDF17719 """
     funcContent="""def comptchev(a,b):
     return "d" not in a
@@ -386,7 +386,7 @@ class SalomeSDSTest(unittest.TestCase):
     self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),value3)
     pass
   
-  def tessTransaction9(self):
+  def testTransaction9(self):
     """ EDF 16833 and EDF17719 : use case 2. Trying to createRdExt during add key session"""
     funcContent="""def comptchev(a,b):
     return a==b
@@ -416,7 +416,7 @@ class SalomeSDSTest(unittest.TestCase):
     pass
 
     
-  def tessLockToDump(self):
+  def testLockToDump(self):
     """ Test to check that holdRequests method. This method wait for clean server status and hold it until activeRequests is called.
     Warning this method expects a not overloaded machine to be run because test is based on ellapse time.
     """
index d77678b910eb39052ce8c869191b17a1de4a7fc0..7f44e3cd97a09298d4feb1a1adf5212335484370 100644 (file)
@@ -39,9 +39,6 @@ def waitKey(IORNS):
     ns = orb.string_to_object(IORNS)
     import SALOME
     dsm = orb.string_to_object(ns.Resolve("/DataServerManager").decode())
-    print(400*"$")
-    print(dsm)
-    print(type(dsm))
     dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
     assert(not isCreated)
     wk=dss.waitForKeyInVar(varName,obj2Str("ef"))
@@ -50,6 +47,4 @@ def waitKey(IORNS):
 
 if __name__=="__main__":
     IORNS = sys.argv[-1]
-    print(50*"#")
-    print(sys.argv)
     sys.exit(not waitKey(IORNS))