]> SALOME platform Git repositories - modules/yacs.git/blobdiff - src/runtime/Test/runtimeTest.cxx
Salome HOME
updated copyright message
[modules/yacs.git] / src / runtime / Test / runtimeTest.cxx
index 68c964de65301b36f44a96c5e40e116865480308..6af3df6a97558dac331b2e52d8e1e1ae68e74f40 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -48,7 +48,7 @@
 #include <cctype>
 #include <cstdlib>
 
-//#define _DEVDEBUG_
+#define _DEVDEBUG_
 #include "YacsTrace.hxx"
 
 using namespace YACS::ENGINE;
@@ -81,6 +81,32 @@ int RuntimeTest::_ibloc = 0;
 Runtime *RuntimeTest::_myRuntime = 0;
 bool RuntimeTest::endTests = false;
 
+RuntimeForTest::RuntimeForTest()
+: RuntimeSALOME(UsePython+UseCorba+UseXml+UseCpp+UseSalome, 0, nullptr)
+{
+}
+
+RuntimeForTest::~RuntimeForTest()
+{
+}
+
+std::vector< std::pair<std::string,int> >
+RuntimeForTest::getCatalogOfComputeNodes() const
+{
+  std::vector< std::pair<std::string,int> > result(1);
+  std::pair<std::string,int> localhost;
+  localhost.first = "localhost";
+  localhost.second = 8;
+  result[0] = localhost;
+  return result;
+}
+
+void RuntimeForTest::setRuntime()
+{
+  if (! Runtime::_singleton)
+    Runtime::_singleton = new RuntimeForTest;
+}
+
 void RuntimeTest::setUp()
 {
   if (_ltc.size() == 0)
@@ -103,7 +129,7 @@ void RuntimeTest::initRuntimeTypeCode()
 {
   // --- init runtime
   std::cerr << std::endl;
-  RuntimeSALOME::setRuntime();
+  RuntimeForTest::setRuntime();
   _myRuntime = getRuntime();
   
   // --- init typecodes
@@ -365,16 +391,16 @@ void RuntimeTest::createPythonNodesWithScript()
     string s = ss.str();
     ElementaryNode* node = _myRuntime->createScriptNode("",s);
     _nodeMap[s] = node;
-    ((InlineNode*) node)->setScript("print 'node 13'\n"
+    ((InlineNode*) node)->setScript("print('node 13')\n"
                                      "import eo\n"
-                                     "print ob\n"
+                                     "print(ob)\n"
                                      "o=ob._narrow(eo.Obj)\n"
-                                     "print o\n"
-                                     "print o.echoLong(13)\n"
+                                     "print(o)\n"
+                                     "print(o.echoLong(13))\n"
                                      "a=dble+1\n"
                                      "dble=2*a\n"
-                                     "print lng\n"
-                                     "print '++++++++',s,'+++++++++++++'\n"
+                                     "print(lng)\n"
+                                     "print('++++++++',s,'+++++++++++++')\n"
                                      "ob=o\n"
                                      "seqstr=['aaa','bbb']\n"
                                      "seqobj=[o,o,o,o]\n"
@@ -413,12 +439,12 @@ void RuntimeTest::createPythonNodesWithScript()
     string s = ss.str();
     ElementaryNode* node = _myRuntime->createScriptNode("",s);
     _nodeMap[s] = node;
-    ((InlineNode*) node)->setScript("print li\n"
-                                     "print 'lili=',lili\n"
-                                     "print 'lstr=',lstr\n"
-                                     "print 'lobj=',lobj\n"
-                                     "print 'llobj=',llobj\n"
-                                     "print 'objc=',objc\n"
+    ((InlineNode*) node)->setScript("print(li)\n"
+                                     "print('lili=',lili)\n"
+                                     "print('lstr=',lstr)\n"
+                                     "print('lobj=',lobj)\n"
+                                     "print('llobj=',llobj)\n"
+                                     "print('objc=',objc)\n"
                                      "li=2*li\n"
                                      );
     InputPort  *i1  = node->edAddInputPort("li",    _tc_seqdble);
@@ -447,12 +473,12 @@ void RuntimeTest::createPythonNodesWithScript()
     string s = ss.str();
     ElementaryNode* node = _myRuntime->createScriptNode("",s);
     _nodeMap[s] = node;
-    ((InlineNode*) node)->setScript("print li\n"
+    ((InlineNode*) node)->setScript("print(li)\n"
                                      "li=[2*e for e in li]\n"
-                                     "print 'obj=',obj\n"
-                                     "print li\n"
-                                     "print lngvec\n"
-                                     "print dblevec\n"
+                                     "print('obj=',obj)\n"
+                                     "print(li)\n"
+                                     "print(lngvec)\n"
+                                     "print(dblevec)\n"
                                      );
     InputPort  *i1  = node->edAddInputPort("li",      _tc_seqdble);
     InputPort  *i2  = node->edAddInputPort("obj",     _tc_obj);
@@ -1155,109 +1181,86 @@ void RuntimeTest::manualExecuteNoThread()
   ((ElementaryNode*)_nodeMap["Node_10"])->load();
   ((ElementaryNode*)_nodeMap["Node_10"])->execute();
   //  CPPUNIT_ASSERT_DOUBLES_EQUAL(10.51, (ElementaryNode*)_nodeMap["Node_10"])
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution Python Node_11" );
-  std::cerr << __LINE__ << std::endl;
   ((ElementaryNode*)_nodeMap["Node_11"])->load();
-  std::cerr << __LINE__ << std::endl;
   ((ElementaryNode*)_nodeMap["Node_11"])->execute();
-  std::cerr << __LINE__ << std::endl;
 
   DEBTRACE(" --- execution Python Node_12" );
   ((ElementaryNode*)_nodeMap["Node_12"])->load();
   ((ElementaryNode*)_nodeMap["Node_12"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_16" );
   ((ElementaryNode*)_nodeMap["Node_16"])->load();
   ((ElementaryNode*)_nodeMap["Node_16"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_17" );
   ((ElementaryNode*)_nodeMap["Node_17"])->load();
   ((ElementaryNode*)_nodeMap["Node_17"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_18" );
   ((ElementaryNode*)_nodeMap["Node_18"])->load();
   ((ElementaryNode*)_nodeMap["Node_18"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_19" );
   ((ElementaryNode*)_nodeMap["Node_19"])->load();
   ((ElementaryNode*)_nodeMap["Node_19"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_20" );
   ((ElementaryNode*)_nodeMap["Node_20"])->load();
   ((ElementaryNode*)_nodeMap["Node_20"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_21" );
   ((ElementaryNode*)_nodeMap["Node_21"])->load();
   ((ElementaryNode*)_nodeMap["Node_21"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_29" );
   ((ElementaryNode*)_nodeMap["Node_29"])->load();
   ((ElementaryNode*)_nodeMap["Node_29"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution Python Node_13" );
   ((ElementaryNode*)_nodeMap["Node_13"])->load();
   ((ElementaryNode*)_nodeMap["Node_13"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_22" );
   ((ElementaryNode*)_nodeMap["Node_22"])->load();
   ((ElementaryNode*)_nodeMap["Node_22"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_23" );
   ((ElementaryNode*)_nodeMap["Node_23"])->load();
   ((ElementaryNode*)_nodeMap["Node_23"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_24" );
   ((ElementaryNode*)_nodeMap["Node_24"])->load();
   ((ElementaryNode*)_nodeMap["Node_24"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_27" );
   ((ElementaryNode*)_nodeMap["Node_27"])->load();
   ((ElementaryNode*)_nodeMap["Node_27"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_28" );
   ((ElementaryNode*)_nodeMap["Node_28"])->load();
   ((ElementaryNode*)_nodeMap["Node_28"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_30" );
   ((ElementaryNode*)_nodeMap["Node_30"])->load();
   ((ElementaryNode*)_nodeMap["Node_30"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_32" );
   ((ElementaryNode*)_nodeMap["Node_32"])->load();
   ((ElementaryNode*)_nodeMap["Node_32"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_26" );
   ((ElementaryNode*)_nodeMap["Node_26"])->load();
   ((ElementaryNode*)_nodeMap["Node_26"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_31" );
   ((ElementaryNode*)_nodeMap["Node_31"])->load();
   ((ElementaryNode*)_nodeMap["Node_31"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution Python Node_14" );
   ((ElementaryNode*)_nodeMap["Node_14"])->load();
   ((ElementaryNode*)_nodeMap["Node_14"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution Python Node_15" );
   ((ElementaryNode*)_nodeMap["Node_15"])->load();
   ((ElementaryNode*)_nodeMap["Node_15"])->execute();
@@ -1267,22 +1270,18 @@ void RuntimeTest::manualExecuteNoThread()
   ((ElementaryNode*)_nodeMap["Node_36"])->load();
   ((ElementaryNode*)_nodeMap["Node_36"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_33" );
   ((ElementaryNode*)_nodeMap["Node_33"])->load();
   ((ElementaryNode*)_nodeMap["Node_33"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_34" );
   ((ElementaryNode*)_nodeMap["Node_34"])->load();
   ((ElementaryNode*)_nodeMap["Node_34"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- execution CORBA Node_35" );
   ((ElementaryNode*)_nodeMap["Node_35"])->load();
   ((ElementaryNode*)_nodeMap["Node_35"])->execute();
 
-  std::cerr << __LINE__ << std::endl;
   DEBTRACE(" --- end of execution" );
 }
 
@@ -1496,7 +1495,7 @@ void RuntimeTest::convertPorts()
     }
 }
 
-void myTestRun(int nIn, int nOut, Any **In, Any **Out) throw (YACS::Exception)
+void myTestRun(int nIn, int nOut, Any **In, Any **Out)
 {
   double x, y;
   cerr << "myTestRun nIn = " << nIn << endl;