From: Ovidiu Mircescu Date: Wed, 24 Jul 2019 13:51:21 +0000 (+0200) Subject: Use /tmp for temporary files needed by salome tests. X-Git-Tag: V9_4_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eda5485fe33a2c578536e7041134d0be8a1f5bb2;p=modules%2Fyacs.git Use /tmp for temporary files needed by salome tests. --- diff --git a/src/engine/Test/engineTest.cxx b/src/engine/Test/engineTest.cxx index 838f68d8c..84f52bd73 100644 --- a/src/engine/Test/engineTest.cxx +++ b/src/engine/Test/engineTest.cxx @@ -1000,7 +1000,7 @@ void EngineTest::RecursiveBlocs_multipleRecursion() DEBTRACE(" output port name for graphe = " << _nodeMap["graphe"]->getOutPortName(*it)); } YACS::ENGINE::VisitorSaveState vst(_compoMap["graphe"]); - vst.openFileDump("dumpState.xml"); + vst.openFileDump("/tmp/RecursiveBlocs_multipleRecursion_dumpState.xml"); _compoMap["graphe"]->accept(&vst); vst.closeFileDump(); } diff --git a/src/pmml/CMakeLists.txt b/src/pmml/CMakeLists.txt index bf549940e..2f4810adf 100644 --- a/src/pmml/CMakeLists.txt +++ b/src/pmml/CMakeLists.txt @@ -110,7 +110,12 @@ ENDIF (NOT URANIE) IF(SALOME_BUILD_TESTS) + SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${LOCAL_TEST_DIR} + RENAME CTestTestfile.cmake) ADD_SUBDIRECTORY(Test) + ENDIF(SALOME_BUILD_TESTS) diff --git a/src/pmml/CTestTestfileInstall.cmake b/src/pmml/CTestTestfileInstall.cmake new file mode 100644 index 000000000..0eb536f16 --- /dev/null +++ b/src/pmml/CTestTestfileInstall.cmake @@ -0,0 +1,25 @@ +# Copyright (C) 2015-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + + +# Add all test subdirs +SUBDIRS( +Test +pmml_swig +) diff --git a/src/pmml/Test/CMakeLists.txt b/src/pmml/Test/CMakeLists.txt index 1f5a936b7..fc2dedea8 100644 --- a/src/pmml/Test/CMakeLists.txt +++ b/src/pmml/Test/CMakeLists.txt @@ -100,7 +100,8 @@ INSTALL(TARGETS TestPMML DESTINATION ${SALOME_INSTALL_BINS}) # -SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml) -FILE(COPY ${PROJECT_SOURCE_DIR}/src/pmml/Test/samples DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}") +SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml/Test) INSTALL(TARGETS TestPMML DESTINATION ${LOCAL_TEST_DIR}) INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${LOCAL_TEST_DIR} RENAME CTestTestfile.cmake) +FILE(GLOB sample_files ${PROJECT_SOURCE_DIR}/src/pmml/Test/samples/*) +INSTALL(FILES ${sample_files} DESTINATION ${LOCAL_TEST_DIR}/samples) diff --git a/src/pmml/Test/CTestTestfileInstall.cmake b/src/pmml/Test/CTestTestfileInstall.cmake index 709b8790f..67bbdc57d 100644 --- a/src/pmml/Test/CTestTestfileInstall.cmake +++ b/src/pmml/Test/CTestTestfileInstall.cmake @@ -21,8 +21,4 @@ IF(NOT WIN32) SET(TEST_NAME ${COMPONENT_NAME}_YacsTestPMML) ADD_TEST(${TEST_NAME} TestPMML) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") - - SET(TEST_NAME ${COMPONENT_NAME}_YacsPMMLBasicsTest) - ADD_TEST(${TEST_NAME} python pmml_swig/PMMLBasicsTestLauncher.py) - SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") ENDIF(NOT WIN32) diff --git a/src/pmml/pmml_swig/CMakeLists.txt b/src/pmml/pmml_swig/CMakeLists.txt index 6d28982bc..cbff66f1c 100644 --- a/src/pmml/pmml_swig/CMakeLists.txt +++ b/src/pmml/pmml_swig/CMakeLists.txt @@ -78,6 +78,15 @@ SET_TESTS_PROPERTIES(PMMLBasicsTest PROPERTIES ENVIRONMENT "${tests_env}") # -SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml/pmml_swig) -FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/PMMLBasicsTest.py DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}") -FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/PMMLBasicsTestLauncher.py DESTINATION "${CMAKE_INSTALL_PREFIX}/${LOCAL_TEST_DIR}") +IF(SALOME_BUILD_TESTS) + SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/pmml/pmml_swig) + INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${LOCAL_TEST_DIR} + RENAME CTestTestfile.cmake) + SET(LOCAL_TEST_FILES + PMMLBasicsTest.py + ) + INSTALL(FILES ${LOCAL_TEST_FILES} + DESTINATION ${LOCAL_TEST_DIR}) + +ENDIF(SALOME_BUILD_TESTS) diff --git a/src/pmml/pmml_swig/CTestTestfileInstall.cmake b/src/pmml/pmml_swig/CTestTestfileInstall.cmake new file mode 100644 index 000000000..5ab2c341f --- /dev/null +++ b/src/pmml/pmml_swig/CTestTestfileInstall.cmake @@ -0,0 +1,24 @@ +# Copyright (C) 2015-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +IF(NOT WIN32) + SET(TEST_NAME ${COMPONENT_NAME}_YacsPMMLBasicsTest) + ADD_TEST(${TEST_NAME} python PMMLBasicsTest.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDIF(NOT WIN32) diff --git a/src/pmml/pmml_swig/PMMLBasicsTestLauncher.py b/src/pmml/pmml_swig/PMMLBasicsTestLauncher.py deleted file mode 100644 index 4a2a8c6fe..000000000 --- a/src/pmml/pmml_swig/PMMLBasicsTestLauncher.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2007-2019 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os,sys,subprocess,shutil - -# Here the most beautiful part of test :) -dirALaCon0="Test" -dirAlaCon1="samples" -if not os.path.exists(dirALaCon0): - os.mkdir(dirALaCon0) -if not os.path.exists(os.path.join(dirALaCon0,dirAlaCon1)): - os.chdir(dirALaCon0) - os.symlink(os.path.join("..",dirAlaCon1),dirAlaCon1) - os.chdir("..") -# GO ! -dn=os.path.dirname(__file__) -p=subprocess.Popen(["python3","PMMLBasicsTest.py"],cwd=dn,stdout=subprocess.PIPE,stderr=subprocess.PIPE) -a,b=p.communicate() -ret=p.returncode -# Clean up the wonderful first part stuf -shutil.rmtree(dirALaCon0) -sys.exit(ret) diff --git a/src/runtime/Test/runtimeTest.sh b/src/runtime/Test/runtimeTest.sh index 7736fb4cf..cdc8669eb 100644 --- a/src/runtime/Test/runtimeTest.sh +++ b/src/runtime/Test/runtimeTest.sh @@ -18,15 +18,16 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -BASEREP=`pwd` -OMNIORB_CONFIG=${BASEREP}/omniorb.cfg -OMNINAMES_LOGDIR=${BASEREP}/omnilog +BASEDIR=`pwd` +TESTDIR=$(mktemp -d --suffix=.yacstest) +OMNIORB_CONFIG=${TESTDIR}/omniorb.cfg +OMNINAMES_LOGDIR=${TESTDIR}/omnilog -export BASEREP +export TESTDIR export OMNIORB_CONFIG export OMNINAMES_LOGDIR -echo ${BASEREP} +echo ${TESTDIR} echo ${OMNIORB_CONFIG} # do not use the default port 2810 for omninames (to improve, cf. SALOME) @@ -48,18 +49,22 @@ sleep 2 pidecho=$! echo $pidecho -if ! [ -f lib/salome/libTestComponentLocal.so ] -then - mkdir -p lib/salome - cp libTestComponentLocal.so lib/salome -fi -export TESTCOMPONENT_ROOT_DIR=`pwd` +# this find should work both for make test and for salome test +mkdir -p ${TESTDIR}/lib/salome +LIBTEST=`find .. -name libTestComponentLocal.so | head -n 1` +cp $LIBTEST ${TESTDIR}/lib/salome + +export TESTCOMPONENT_ROOT_DIR=${TESTDIR} #wait enough time to let runtimeTestEchoSrv start and register sleep 2 +cp xmlrun.sh ${TESTDIR} +cp TestRuntime ${TESTDIR} +cd ${TESTDIR} ./TestRuntime ret=$? +cd - kill -9 $pidecho $pidomni cat /tmp/${USER}/UnitTestsResult diff --git a/src/yacsloader/Test/YacsLoaderInSessionTest.sh.in b/src/yacsloader/Test/YacsLoaderInSessionTest.sh.in index 5557af76d..b6fda9cb1 100755 --- a/src/yacsloader/Test/YacsLoaderInSessionTest.sh.in +++ b/src/yacsloader/Test/YacsLoaderInSessionTest.sh.in @@ -40,7 +40,11 @@ export PYTHONPATH=@CMAKE_CURRENT_SOURCE_DIR@:$PYTHONPATH # --- launch unit tests export ROOT_SAMPLES=@CMAKE_SOURCE_DIR@/src/yacsloader/samples -export TESTCOMPONENT_ROOT_DIR=@CMAKE_BINARY_DIR@/src/runtime/Test +export TESTCOMPONENT_ROOT_DIR=$(mktemp -d --suffix=.yacstest) + +mkdir -p ${TESTCOMPONENT_ROOT_DIR}/lib/salome +LIBTEST=`find ../.. -name libTestComponentLocal.so | head -n 1` +cp $LIBTEST ${TESTCOMPONENT_ROOT_DIR}/lib/salome ./TestYacsLoader ret=$? diff --git a/src/yacsloader/Test/runYacsLoaderTest.sh b/src/yacsloader/Test/runYacsLoaderTest.sh index 5402a5220..8dbe02672 100644 --- a/src/yacsloader/Test/runYacsLoaderTest.sh +++ b/src/yacsloader/Test/runYacsLoaderTest.sh @@ -22,12 +22,24 @@ ./echoSrv & pidecho=$! -export TESTCOMPONENT_ROOT_DIR=`pwd`/../runtime +BASEDIR=`pwd` +TESTDIR=$(mktemp -d --suffix=.yacstest) +export TESTCOMPONENT_ROOT_DIR=${TESTDIR} -./TestYacsLoader +mkdir -p ${TESTDIR}/lib/salome +LIBTEST=$BASEDIR/../runtime/lib/salome/libTestComponentLocal.so +cp $LIBTEST ${TESTDIR}/lib/salome +LIBDIR=$BASEDIR/../lib + +cp xmlrun.sh $TESTDIR +cp *.py $TESTDIR +ln -s $BASEDIR/samples $TESTDIR/samples +cd $TESTDIR +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBDIR $BASEDIR/TestYacsLoader ret=$? +cd $BASEDIR echo "exec status TestYacsLoader " $ret kill -9 $pidecho -exit $ret \ No newline at end of file +exit $ret diff --git a/src/yacsloader_swig/Test/CMakeLists.txt b/src/yacsloader_swig/Test/CMakeLists.txt index f5abf6b9a..a1ff64355 100644 --- a/src/yacsloader_swig/Test/CMakeLists.txt +++ b/src/yacsloader_swig/Test/CMakeLists.txt @@ -46,6 +46,7 @@ IF(NOT WIN32) testValidationChecks.py testProgress.py testExecForEachGeoMesh.py + async_plugin.py ) INSTALL(FILES ${LOCAL_TEST_FILES} DESTINATION ${LOCAL_TEST_DIR}) diff --git a/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py b/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py index 042058ff0..d5df2d064 100644 --- a/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py +++ b/src/yacsloader_swig/Test/StdAloneYacsLoaderTest1.py @@ -21,6 +21,8 @@ import pilot import SALOMERuntime import loader import unittest +import tempfile +import os class StdAloneYacsLoaderTest1(unittest.TestCase): @@ -28,6 +30,7 @@ class StdAloneYacsLoaderTest1(unittest.TestCase): SALOMERuntime.RuntimeSALOME_setRuntime() self.r = pilot.getRuntime() self.l = loader.YACSLoader()# self.l.load("foreachImbr_tmp.xml") + self.workdir = tempfile.mkdtemp(suffix=".yacstest") pass def test1(self): @@ -80,14 +83,15 @@ class StdAloneYacsLoaderTest1(unittest.TestCase): self.assertEqual(p.getState(),pilot.DONE) zeResu=node3.getOutputPort("o3").get() self.assertEqual(zeResu,[[[3.,3.],[4.,4.,4.]],[[12.],[13.,13.],[14.,14.,14.]],[[22.],[23.,23.],[24.,24.,24.],[25.,25.,25.,25.]]]) - p.saveSchema("foreachImbrBuildFS.xml") + fname = os.path.join(self.workdir, "foreachImbrBuildFS.xml") + p.saveSchema(fname) pass def test2(self): """ Non regression test. When input/output declared as pyobj hiding a string type to go to or from a ForEachLoop it previous lead to an error. """ - fname="BugPyObjStrInYacs.xml" + fname=os.path.join(self.workdir, "BugPyObjStrInYacs.xml") p=self.r.createProc("pr") tc0=p.createInterfaceTc("python:obj:1.0","pyobj",[]) tc1=p.createSequenceTc("list[pyobj]","list[pyobj]",tc0) @@ -131,7 +135,7 @@ class StdAloneYacsLoaderTest1(unittest.TestCase): def test3(self): """ Non regression test Mantis 23234 CEA1726""" - fname="test23234.xml" + fname=os.path.join(self.workdir, "test23234.xml") p=self.r.createProc("Test23234") ti=p.createType("int","int") initNode=self.r.createScriptNode("","init") @@ -178,7 +182,6 @@ def sum(i): def test4(self): """ test linked to TestSaveLoadRun.test20. This is a smaller test coming from EDF autotest""" - xmlFileName="test4.xml" p=self.r.createProc("test26") n=self.r.createScriptNode("","node1") n.setScript("import os") @@ -195,7 +198,7 @@ def sum(i): def test5(self): """ Test focusing P13268. If I connect a list[pyobj] output inside a ForEach to a list[pyobj] outside a foreach it works now.""" #self.assertTrue(False) - fname="testP1328.xml" + fname=os.path.join(self.workdir, "testP1328.xml") p=self.r.createProc("testP1328") tc0=p.createInterfaceTc("python:obj:1.0","pyobj",[]) tc1=p.createSequenceTc("list[pyobj]","list[pyobj]",tc0) @@ -232,7 +235,7 @@ def sum(i): def test6(self): """ Test focusing on P13766. Test of a connection of 2 foreach at same level where the output pyobj is connected to the list[pyobj] input samples of the 2nd foreach""" - fname="testP13766.xml" + fname=os.path.join(self.workdir, "testP13766.xml") p=self.r.createProc("testP13766") tc0=p.createInterfaceTc("python:obj:1.0","pyobj",[]) tc1=p.createSequenceTc("list[pyobj]","list[pyobj]",tc0) @@ -278,52 +281,6 @@ def sum(i): def test7(self): """EDF17963 : Python3 porting. Py3 Pickeling generates more often byte(0) into the bytes. This reveals an incorrect management of Python Bytes -> Any String that leads to truncated bytes.""" - async_algo_script="""import SALOMERuntime - -class myalgosync(SALOMERuntime.OptimizerAlgSync): - def __init__(self): - SALOMERuntime.OptimizerAlgSync.__init__(self, None) - r=SALOMERuntime.getSALOMERuntime() - self.tin=r.getTypeCode("double") - self.tout=r.getTypeCode("int") - self.tAlgoInit=r.getTypeCode("pyobj") - self.tAlgoResult=r.getTypeCode("pyobj") - - def setPool(self,pool): - print("Algo setPool") - - def getTCForIn(self): - return self.tin - - def getTCForOut(self): - return self.tout - - def getTCForAlgoInit(self): - return self.tAlgoInit - - def getTCForAlgoResult(self): - return self.tAlgoResult - - def initialize(self,input): - print ("Algo initialize") - - def start(self): - print ("Algo start") - - def takeDecision(self): - print ("Algo takeDecision") - - def finish(self): - print ("Algo finish") - - def getAlgoResult(self): - print("Algo getAlgoResult : on charge un objet complet obtenu en pickle 9.2 avant tuyau") - import pickle - import numpy as np - resu = np.array(range(1),dtype=np.int32) - ob=pickle.dumps(resu,protocol=0) - assert(bytes([0]) in ob) # test is here presence of 0 in the pickelization - return ob""" entree_script="""Study = "toto" print("Entree", Study)""" @@ -337,14 +294,10 @@ assert(isinstance(resultats,np.ndarray)) """ nbWorkers=1 - fname="test7.xml" SALOMERuntime.RuntimeSALOME.setRuntime() r=SALOMERuntime.getSALOMERuntime() # - with open("async_plugin.py","w") as f: - f.write(async_algo_script) - # p0=r.createProc("run") # td=p0.createType("double","double") diff --git a/src/yacsloader_swig/Test/async_plugin.py b/src/yacsloader_swig/Test/async_plugin.py new file mode 100644 index 000000000..c125823cd --- /dev/null +++ b/src/yacsloader_swig/Test/async_plugin.py @@ -0,0 +1,46 @@ +import SALOMERuntime + +class myalgosync(SALOMERuntime.OptimizerAlgSync): + def __init__(self): + SALOMERuntime.OptimizerAlgSync.__init__(self, None) + r=SALOMERuntime.getSALOMERuntime() + self.tin=r.getTypeCode("double") + self.tout=r.getTypeCode("int") + self.tAlgoInit=r.getTypeCode("pyobj") + self.tAlgoResult=r.getTypeCode("pyobj") + + def setPool(self,pool): + print("Algo setPool") + + def getTCForIn(self): + return self.tin + + def getTCForOut(self): + return self.tout + + def getTCForAlgoInit(self): + return self.tAlgoInit + + def getTCForAlgoResult(self): + return self.tAlgoResult + + def initialize(self,input): + print ("Algo initialize") + + def start(self): + print ("Algo start") + + def takeDecision(self): + print ("Algo takeDecision") + + def finish(self): + print ("Algo finish") + + def getAlgoResult(self): + print("Algo getAlgoResult : on charge un objet complet obtenu en pickle 9.2 avant tuyau") + import pickle + import numpy as np + resu = np.array(range(1),dtype=np.int32) + ob=pickle.dumps(resu,protocol=0) + assert(bytes([0]) in ob) # test is here presence of 0 in the pickelization + return ob diff --git a/src/yacsloader_swig/Test/testExec.py b/src/yacsloader_swig/Test/testExec.py index 270fcf98a..b548fb9b3 100755 --- a/src/yacsloader_swig/Test/testExec.py +++ b/src/yacsloader_swig/Test/testExec.py @@ -21,6 +21,8 @@ import time import unittest import threading +import tempfile +import os import SALOMERuntime import loader @@ -33,6 +35,7 @@ class TestExec(unittest.TestCase): self.l = loader.YACSLoader() self.e = pilot.ExecutorSwig() self.p = self.l.load("samples/aschema.xml") + self.workdir = tempfile.mkdtemp(suffix=".yacstest") pass def test1_StepByStep(self): @@ -142,7 +145,7 @@ class TestExec(unittest.TestCase): run4.start() time.sleep(0.1) self.e.waitPause() - self.e.saveState("dumpErrorASchema.xml") + self.e.saveState(os.path.join(self.workdir, "dumpErrorASchema.xml")) self.e.setStopOnError(False) self.e.resumeCurrentBreakPoint() time.sleep(0.1) @@ -169,7 +172,7 @@ class TestExec(unittest.TestCase): time.sleep(0.1) self.e.waitPause() #self.e.displayDot(self.p) - self.e.saveState('dumpPartialASchema.xml') + self.e.saveState(os.path.join(self.workdir, 'dumpPartialASchema.xml')) #self.e.displayDot(self.p) self.e.stopExecution() run5.join() diff --git a/src/yacsloader_swig/Test/testResume.py b/src/yacsloader_swig/Test/testResume.py index 3d6d0f0f6..a63c8a13d 100755 --- a/src/yacsloader_swig/Test/testResume.py +++ b/src/yacsloader_swig/Test/testResume.py @@ -21,6 +21,8 @@ import time import unittest import threading +import tempfile +import os import SALOMERuntime import loader @@ -33,6 +35,8 @@ class TestResume(unittest.TestCase): self.l = loader.YACSLoader() self.e = pilot.ExecutorSwig() self.p = self.l.load("samples/bloc2.xml") + workdir = tempfile.mkdtemp(suffix=".yacstest") + self.statefile = os.path.join(workdir, 'dumpPartialBloc2.xml') pass def test1_PartialExec(self): @@ -49,23 +53,21 @@ class TestResume(unittest.TestCase): time.sleep(0.1) self.e.waitPause() #self.e.displayDot(self.p) - self.e.saveState('dumpPartialBloc2.xml') + self.e.saveState(self.statefile) #self.e.displayDot(self.p) self.e.stopExecution() #self.e.displayDot(self.p) self.assertEqual(101, self.p.getChildByName('b1.b2.node1').getEffectiveState()) self.assertEqual(106, self.p.getChildByName('b1.node1').getEffectiveState()) print("================= reach BREAKPOINT PARTIAL EXEC ==========") - pass - def test2_ExecFromLoadState(self): # --- reload state from previous partial execution then exec time.sleep(1) print("================= Start of EXECLOADEDSTATE ===============") sp = loader.stateParser() sl = loader.stateLoader(sp,self.p) - sl.parse('dumpPartialBloc2.xml') + sl.parse(self.statefile) #self.e.displayDot(self.p) self.e.setExecMode(0) # YACS::CONTINUE run2 = threading.Thread(None, self.e.RunPy, "loadState", (self.p,0,True,True)) diff --git a/src/yacsloader_swig/Test/testSave.py b/src/yacsloader_swig/Test/testSave.py index c7169352d..c7caed775 100755 --- a/src/yacsloader_swig/Test/testSave.py +++ b/src/yacsloader_swig/Test/testSave.py @@ -21,6 +21,8 @@ import time import unittest import threading +import tempfile +import os import SALOMERuntime import loader @@ -30,6 +32,7 @@ class TestSave(unittest.TestCase): def setUp(self): SALOMERuntime.RuntimeSALOME_setRuntime(1) + self.workdir = tempfile.mkdtemp(suffix=".yacstest") pass def test0_saveAndExec(self): @@ -54,10 +57,10 @@ class TestSave(unittest.TestCase): e = pilot.ExecutorSwig() for schema in schemaList: fileOrig = "samples/" + schema + ".xml" - saveSchema1 = "schema1_" + schema - dumpSchema1 = "dump1_" + schema - saveSchema2 = "schema2_" + schema - dumpSchema2 = "dump2_" + schema + saveSchema1 = os.path.join(self.workdir, "schema1_" + schema) + dumpSchema1 = os.path.join(self.workdir, "dump1_" + schema) + saveSchema2 = os.path.join(self.workdir, "schema2_" + schema) + dumpSchema2 = os.path.join(self.workdir, "dump2_" + schema) try: p = l.load(fileOrig) s = pilot.SchemaSave(p) diff --git a/src/yacsloader_swig/Test/testSaveLoadRun.py b/src/yacsloader_swig/Test/testSaveLoadRun.py index 33babb3c4..bbbb58acb 100755 --- a/src/yacsloader_swig/Test/testSaveLoadRun.py +++ b/src/yacsloader_swig/Test/testSaveLoadRun.py @@ -18,6 +18,9 @@ # import unittest +import tempfile +import os + import pilot import SALOMERuntime import loader @@ -28,11 +31,12 @@ class TestSaveLoadRun(unittest.TestCase): def setUp(self): SALOMERuntime.RuntimeSALOME.setRuntime() self.r=SALOMERuntime.getSALOMERuntime() + self.workdir = tempfile.mkdtemp(suffix=".yacstest") pass def test0(self): """First test of HP Container no loop here only the 3 sorts of python nodes (the Distributed is it still used and useful ?) """ - fname="TestSaveLoadRun0.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun0.xml") nbOfNodes=8 sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node l=loader.YACSLoader() @@ -125,7 +129,7 @@ print("coucou from script1-%i -> %s"%(dbg,str(datetime.datetime.now()-ref))) def test1(self): """ HP Container again like test0 but the initialization key of HPContainer is used here.""" - fname="TestSaveLoadRun1.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun1.xml") nbOfNodes=8 sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node l=loader.YACSLoader() @@ -234,7 +238,7 @@ o3=0 """ script2="""o9=sum(i8) """ - fname="TestSaveLoadRun2.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun2.xml") nbOfNodes=8 sqrtOfNumberOfTurn=1000 # 3000 -> 3.2s/Node, 1000 -> 0.1s/Node l=loader.YACSLoader() @@ -331,7 +335,7 @@ o3=0 """ script2="""o9=sum(i8) """ - fname="TestSaveLoadRun3.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun3.xml") nbOfNodes=8 sqrtOfNumberOfTurn=10 l=loader.YACSLoader() @@ -408,7 +412,7 @@ o3=0 def test4(self): """Non regression test of multi pyScriptNode, pyFuncNode sharing the same HPContainer instance.""" - fname="TestSaveLoadRun4.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun4.xml") script1="""nb=7 ii=0 o1=nb*[None] @@ -493,7 +497,7 @@ for i in range(nb): def test5(self): """Non regression test 2 of multi pyNode, pyFuncNode sharing the same HPContainer instance.""" - fname="TestSaveLoadRun5.xml" + fname=os.path.join(self.workdir, "TestSaveLoadRun5.xml") script1="""nb=7 ii=0 o1=nb*[None] @@ -579,7 +583,7 @@ for i in range(nb): pass def test6(self): - fname="test6.xml" + fname=os.path.join(self.workdir, "test6.xml") p=self.r.createProc("prTest0") td=p.createType("double","double") ti=p.createType("int","int") @@ -626,7 +630,7 @@ for i in range(nb): pass def test7(self): - fname="test7.xml" + fname=os.path.join(self.workdir, "test7.xml") p=self.r.createProc("prTest1") cont=p.createContainer("gg","Salome") cont.setProperty("name","localhost") @@ -687,7 +691,7 @@ else: def test8(self): from datetime import datetime - fname="test8.xml" + fname=os.path.join(self.workdir, "test8.xml") p=self.r.createProc("prTest2") cont=p.createContainer("gg","Salome") cont.setProperty("name","localhost") @@ -773,7 +777,7 @@ else: def test9(self): """ Test of assignation of already computed values for foreach node.""" - fname="test9.xml" + fname=os.path.join(self.workdir, "test9.xml") from datetime import datetime p=self.r.createProc("prTest2") cont=p.createContainer("gg","Salome") @@ -855,7 +859,7 @@ o2=7*i1 pass def test10(self): - fname="test10.xml" + fname=os.path.join(self.workdir, "test10.xml") from datetime import datetime p=self.r.createProc("prTest2") cont=p.createContainer("gg","Salome") @@ -945,7 +949,7 @@ else: def test11(self): "test if we do not restart from the begining of the schema after an error in a foreach" - fname="test11.xml" + fname=os.path.join(self.workdir, "test11.xml") from datetime import datetime p=self.r.createProc("prTest2") cont=p.createContainer("gg","Salome") @@ -1173,7 +1177,7 @@ for i in i8: def test14(self): """ Non regression EDF11027. Problem after Save/Load of a foreach node with type pyobj with input "SmplsCollection" manually set before. Correction in convertToYacsObjref from XML->Neutral. Objref can hide a string !""" - xmlFileName="test14.xml" + xmlFileName=os.path.join(self.workdir, "test14.xml") SALOMERuntime.RuntimeSALOME_setRuntime() r=pilot.getRuntime() n0=r.createProc("test23/zeRun") @@ -1214,7 +1218,7 @@ for i in i8: pass def test15(self): - fname="BugInConcurrentLaunchDftCont.xml" + #fname=os.path.join(self.workdir, "BugInConcurrentLaunchDftCont.xml") p=self.r.createProc("pr") ti=p.createType("int","int") cont=p.createContainer("DefaultContainer","Salome") @@ -1318,7 +1322,7 @@ for i in i8: def test19(self): """This test checks the mechanism of YACS that allow PythonNodes to know their DynParaLoop context.""" - fname="test19.xml" + fname=os.path.join(self.workdir, "test19.xml") l=loader.YACSLoader() # p=self.r.createProc("PROC") @@ -1461,8 +1465,8 @@ dd=range(10)""") def test21(self): "test if we restart from a saved state in a foreach loop" - fname="test21.xml" - xmlStateFileName="saveState21.xml" + fname=os.path.join(self.workdir, "test21.xml") + xmlStateFileName=os.path.join(self.workdir, "saveState21.xml") from datetime import datetime p=self.r.createProc("prTest21") cont=p.createContainer("gg","Salome") @@ -1537,22 +1541,14 @@ o2=5*i1 p.getChildByName("n1").assignPassedResults(a,b,c) p.exUpdateState(); # - startt=datetime.now() ex.RunW(p,0,False) - t1=datetime.now()-startt # self.assertEqual(n1.getState(),pilot.DONE) self.assertEqual(p.getState(),pilot.DONE) self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0,2,10,15,20,25]) - pass - pass - def test22(self): - """Restart from a saved state in a foreach loop without using assignPassedResults. - This test uses the files test21.xml and saveState21.xml produced by test21. - """ - fname="test21.xml" - xmlStateFileName="saveState21.xml" + # Restart from a saved state in a foreach loop without using assignPassedResults. + # This test uses the files test21.xml and saveState21.xml produced by test21. ex=pilot.ExecutorSwig() l=loader.YACSLoader() @@ -1582,9 +1578,7 @@ o4=i3 def test23(self): """ test focused on weight attribut after a dump and reload from a xml file """ - fname="test23.xml" - xmlStateFileName="saveState23.xml" - from datetime import datetime + fname=os.path.join(self.workdir, "test23.xml") p=self.r.createProc("prTest23") cont=p.createContainer("gg","Salome") cont.setProperty("name","localhost") @@ -1757,7 +1751,7 @@ t1.addKeyValueInVarErrorIfAlreadyExistingNow(obj2Str("ef"),obj2Str([11,12])) pass def test25(self): - fname="test25.xml" + fname=os.path.join(self.workdir, "test25.xml") p=self.r.createProc("p0") tp=p.createInterfaceTc("python:obj:1.0","pyobj",[]) n1_0_sc=self.r.createScriptNode("Salome","n1_0_sc") @@ -1790,7 +1784,7 @@ t1.addKeyValueInVarErrorIfAlreadyExistingNow(obj2Str("ef"),obj2Str([11,12])) import os content_of_file = b'DDkShXM2PeNCndPqRfnYX5EAt.GaRgPq7dNqtfnYZgvqh=kQf7moXCE2z5lED.tCxgM2RcOqdfl29ePC9YnAx3uaGetqF5lE=.E2D0uS1eM2RcOqdfl2FjPqBYE2pdNq7fl2FjPqBYHoT3.2=.Ew9dsCdUFqVfOaj2Eaxet4BeN2=BOKRWOwF0PqfYMqdYHoT3.2=.EwxYNKHeNa=5O4heOwF4OKBeN2=7Maj2FaZXOaFDFwI.E2=1kibUua=5O4heOwF7Nq9YE2pdNq7fl2ZbMiFDFwI.E2=1nqFZNCdaM2RcOqdfl21dvqFZN2=7Maj2ECbWsKxbNQxYNKL6lo12HoT3.2=.EwneOCfeNqleM2RcOqdfl2BdPC9hcCbjN4Jfd2=APqRWuaRWuwF.uSxYNKFDFwI.E2=1kibUua=5O4heOwFAsiHdNqtYE2pdNq7fl2nWtCZbPaFDFwI.E2=1n4xbMiVdNqdYs2RcOqdfl26eNaVesq9g9qRWu4ZbOaHYFwI.E2=.E2=1kCHjMCdYsibUFqVfOaj2H4xbMiVdNqdYvupdNq7YE2PcMqfeOwFAe4BjOqdYHoT3.2=.E2=.Ew1Yvq1eNC9ds2RcOqdfl2VWsiVgMKdWPuxbPulXPqRdNqtYE2PcMqfeOwF.l2x5lE=.E2=.E2D.tCxUuaHWuS=5O4heOwFAPqRWu4ZbOaHjd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X17ER1nonWtCZbPaT1noPcMqfeNwI1liVXOidbkwnWtCZbPaT17AAZ=oDDHC9YuKRiNwDDFiVXOidblED4u4BeuaT1nC9YuKRiNwAgkmI5EwxAsiHdNqtbkwx4u4BeuaT3.wPcMqfeNwDAsiHdNqtbkm917ER1nonWtCZbPaT1noPcMqfeNwI1liVXOidbkwnWtCZbPaT18gAZ=oDDHC9YuKRiNwDDFiVXOidblED4u4BeuaT1nC9YuKRiNwAakmI5EwxAsiHdNqtbkwx4u4BeuaT3.wPcMqfeNwDAsiHdNqtbkmv17ER1nonWtCZbPaT1noPcMqfeNwI1liVXOidbkwnWtCZbPaT16QAZ=oDDHC9YuKRiNwDDFiVXOidblED4u4BeuaT1nC9YuKRiNwAdkmI5EwxAsiHdNqtbkwx4u4BeuaT3.wx0O49cNwDDG4HYu4bbkwx4u4BeuaT3.2=.Ewx.u4HcOqdWuaHblE=.E2D.u4HcOqdWuaHblE=.E2=.E2D0vqRjMadbkidgsiHAnohcOKRbEidgsiHAnoHetqR0uanWtAnDFWcbEidgsiHAnoHetqydNq9eNCRcMqDDEixbPq7eNwD0vq1jNC9bmKX1no9jMCxYsiT3.2=.E2=.EwPcMqfeNwDDN4JYuaNbkwVBf06c6eUhcmn17ER9euT1noxYNKHeNaT1noPcMqfeNwI.E2=1no1cNCVfOa9eNCT3.wx.tCxgNwI3' - fname="test_930.xml" + fname=os.path.join(self.workdir, "test_930.xml") with open(fname,"wb") as f: f.write( pilot.FromBase64Swig(content_of_file) )