From 22c913d13edf320b3cf019e7fb2c943265a6e1f1 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 22 Jul 2015 10:52:29 +0200 Subject: [PATCH] Put test in salome test mechanism. --- CTestTestfileInstall.cmake.in | 1 + src/SALOMESDS/CMakeLists.txt | 6 +++-- src/SALOMESDS/CTestTestfileInstall.cmake | 23 +++++++++++++++++++ .../{TestSalomeSDS2.py => TestSalomeSDS.py} | 14 +++++------ ...tSalomeSDS3.py => TestSalomeSDSHelper0.py} | 0 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 src/SALOMESDS/CTestTestfileInstall.cmake rename src/SALOMESDS/{TestSalomeSDS2.py => TestSalomeSDS.py} (92%) rename src/SALOMESDS/{TestSalomeSDS3.py => TestSalomeSDSHelper0.py} (100%) diff --git a/CTestTestfileInstall.cmake.in b/CTestTestfileInstall.cmake.in index b739c2e22..05f1720ca 100644 --- a/CTestTestfileInstall.cmake.in +++ b/CTestTestfileInstall.cmake.in @@ -36,6 +36,7 @@ SUBDIRS( Launcher KernelHelpers SALOMEDS SALOMEDSImpl + SALOMESDS Utils UnitTests connect diff --git a/src/SALOMESDS/CMakeLists.txt b/src/SALOMESDS/CMakeLists.txt index 259f95a91..79ca214dc 100644 --- a/src/SALOMESDS/CMakeLists.txt +++ b/src/SALOMESDS/CMakeLists.txt @@ -56,7 +56,9 @@ ADD_EXECUTABLE(SALOME_DataScopeServer SALOME_DataScopeServer.cxx) TARGET_LINK_LIBRARIES(SALOME_DataScopeServer SalomeSDS) INSTALL(TARGETS SALOME_DataScopeServer DESTINATION ${SALOME_INSTALL_BINS}) INSTALL(FILES SalomeSDSClt.py DESTINATION ${SALOME_INSTALL_BINS}) -INSTALL(FILES TestSalomeSDS3.py DESTINATION ${SALOME_INSTALL_BINS}) - FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) +# tests part +SET(LOCAL_TEST_DIR ${KERNEL_TEST_DIR}/SALOMESDS) +INSTALL(FILES TestSalomeSDS.py TestSalomeSDSHelper0.py DESTINATION ${LOCAL_TEST_DIR}) +INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${LOCAL_TEST_DIR} RENAME CTestTestfile.cmake) diff --git a/src/SALOMESDS/CTestTestfileInstall.cmake b/src/SALOMESDS/CTestTestfileInstall.cmake new file mode 100644 index 000000000..bb8894679 --- /dev/null +++ b/src/SALOMESDS/CTestTestfileInstall.cmake @@ -0,0 +1,23 @@ +# Copyright (C) 2015 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) + ADD_TEST(TestSalomeSDS python ${SALOME_TEST_DRIVER} ${TIMEOUT} TestSalomeSDS.py) + SET_TESTS_PROPERTIES(TestSalomeSDS PROPERTIES LABELS "${COMPONENT_NAME}" ENVIRONMENT "PYTHONPATH=${KERNEL_TEST_LIB}:$ENV{PYTHONPATH}") +ENDIF(NOT WIN32) diff --git a/src/SALOMESDS/TestSalomeSDS2.py b/src/SALOMESDS/TestSalomeSDS.py similarity index 92% rename from src/SALOMESDS/TestSalomeSDS2.py rename to src/SALOMESDS/TestSalomeSDS.py index 21fe1671f..8bae455a3 100644 --- a/src/SALOMESDS/TestSalomeSDS2.py +++ b/src/SALOMESDS/TestSalomeSDS.py @@ -45,9 +45,9 @@ def work(t): generateKey(varName,scopeName) return 0 else: - import TestSalomeSDS3 + import TestSalomeSDSHelper0 import os,subprocess - fname=os.path.splitext(TestSalomeSDS3.__file__)[0]+".py" + fname=os.path.splitext(TestSalomeSDSHelper0.__file__)[0]+".py" proc=subprocess.Popen(["python",fname],stdout=subprocess.PIPE,stderr=subprocess.PIPE) out,err=proc.communicate() if proc.returncode!=0: @@ -55,7 +55,7 @@ def work(t): print err return proc.returncode -class SalomeSDS2Test(unittest.TestCase): +class SalomeSDSTest(unittest.TestCase): def testList1(self): a=SalomeSDSClt.CreateRdExtGlobalVar([],"a","Scope0") @@ -111,7 +111,7 @@ class SalomeSDS2Test(unittest.TestCase): if scopeName in dsm.listScopes(): dsm.removeDataScope(scopeName) dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName) - assert(isCreated) + self.assertTrue(isCreated) # t0=dss.createRdExtVarTransac(varName,obj2Str({"ab":[4,5,6]})) dss.atomicApply([t0]) @@ -119,14 +119,14 @@ class SalomeSDS2Test(unittest.TestCase): t1=dss.addKeyValueInVarHard(varName,obj2Str("cd"),obj2Str([7,8,9,10])) dss.atomicApply([t1]) # - assert(str2Obj(dss.fetchSerializedContent(varName))=={'ab':[4,5,6],'cd':[7,8,9,10]}) + self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]}) wk=dss.waitForKeyInVar(varName,obj2Str("cd")) - assert(str2Obj(wk.waitFor())==[7,8,9,10]) + self.assertEqual(str2Obj(wk.waitFor()),[7,8,9,10]) # nbProc=8 pool=mp.Pool(processes=nbProc) asyncResult=pool.map_async(work,[(i,varName,scopeName) for i in xrange(nbProc)]) - assert(asyncResult.get()==nbProc*[0]) + self.assertEqual(asyncResult.get(),nbProc*[0]) # <- the big test is here ! dsm.removeDataScope(scopeName) def setUp(self): diff --git a/src/SALOMESDS/TestSalomeSDS3.py b/src/SALOMESDS/TestSalomeSDSHelper0.py similarity index 100% rename from src/SALOMESDS/TestSalomeSDS3.py rename to src/SALOMESDS/TestSalomeSDSHelper0.py -- 2.39.2