ENABLE_TESTING()
-INCLUDE(tests.set)
+# get all restricted HDF tests
+SET(hdfFilesRestr "")
+IF (EXISTS $ENV{RESTRICTED_ROOT_DIR})
+ FILE(GLOB hdfFilesRestr "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
+ENDIF()
+
+# get all HDF tests from the current drectory
+file(GLOB hdfFilesCur "${CMAKE_CURRENT_SOURCE_DIR}/*.hdf")
+
+# collect test names
+set(TEST_NAMES "")
+foreach(eachFilePath IN LISTS hdfFilesCur hdfFilesRestr)
+ # Strip the ".hdf" suffix
+ get_filename_component(aTestName ${eachFilePath} NAME_WE)
+ # Check corresponding ".py" file with reference data exists
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
+ set(TEST_NAMES ${TEST_NAMES} ${aTestName})
+ else()
+ message(WARNING "File ${aTestName}.py containing reference data for ${aTestName}.hdf does not exist")
+ endif()
+endforeach()
SET(COMPONENT_NAME SHAPER)
SET(TIMEOUT 600)
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+SET(PUBLIC_TESTS "")
+SET(RESTRICTED_TESTS "")
FOREACH(tfile ${TEST_NAMES})
SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile})
- GET_HDF(HDF_TEST_FILE ${tfile})
+
+ IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
+ SET(HDF_TEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
+ SET(PUBLIC_TESTS ${PUBLIC_TESTS} ${tfile})
+ ELSEIF(EXISTS "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
+ SET(HDF_TEST_FILE "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
+ SET(RESTRICTED_TESTS ${RESTRICTED_TESTS} ${tfile})
+ ENDIF()
+
ADD_TEST(NAME ${TEST_NAME}
- COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${HDF_TEST_FILE}")
+ COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "${HDF_TEST_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py")
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1")
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};models_hdf")
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT ${TIMEOUT})
DESTINATION ${TEST_INSTALL_DIRECTORY}
RENAME CTestTestfile.cmake)
-INSTALL(FILES testme.py DESTINATION ${TEST_INSTALL_DIRECTORY})
-INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(FILES testme.py DESTINATION ${TEST_INSTALL_DIRECTORY}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
+FILE(COPY test_hdf.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+CONFIGURE_FILE(tests.set.in ${CMAKE_CURRENT_BINARY_DIR}/tests.set @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
INCLUDE(tests.set)
-SET(COMPONENT_NAME SHAPER)
-SET(TIMEOUT 600)
+SET(COMPONENT_NAME SHAPER)
+SET(SALOME_TEST_DRIVER "testme.py")
+SET(TIMEOUT 600)
-FOREACH(tfile ${TEST_NAMES})
+FOREACH(tfile ${PUBLIC_TESTS})
SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile})
- GET_HDF(HDF_TEST_FILE ${tfile})
- ADD_TEST(NAME ${TEST_NAME}
- COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${HDF_TEST_FILE}")
+ ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} "${TIMEOUT}" "${tfile}.hdf" "${tfile}.py")
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
+
+FOREACH(tfile ${RESTRICTED_TESTS})
+ SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile})
+ ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} "${TIMEOUT}" "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf" "${tfile}.py")
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
- SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT ${TIMEOUT})
ENDFOREACH()
def setUp(self):
salome.salome_close()
- # leave file name only (trim path and extension)
- fileName = os.path.basename(self.testfile)
- self.reffile = self.reffile + "/" + os.path.splitext(fileName)[0] + ".py"
-
salome.salome_init(self.testfile, embedded=1)
myStudyName = salome.myStudy._get_Name()
self.session = salome.naming_service.Resolve('/Kernel/Session')
if len(sys.argv) > 1:
TestHDF.testfile = sys.argv[1]
if len(sys.argv) > 2:
- salomePortFile = sys.argv[2]
+ TestHDF.reffile = sys.argv[2]
if len(sys.argv) > 3:
- errFile = open(sys.argv[3], 'w')
+ salomePortFile = sys.argv[3]
if len(sys.argv) > 4:
- salomeKernelDir = sys.argv[4]
- if len(sys.argv) > 5:
- TestHDF.reffile = sys.argv[5]
+ errFile = open(sys.argv[4], 'w')
aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF)
unittest.TextTestRunner(stream=errFile).run(aTest)
# close Salome GUI
port = salome_utils.getPortNumber()
- proc = subprocess.Popen([salomeKernelDir + "/bin/salome/killSalomeWithPort.py", "{}".format(port)])
+ proc = subprocess.Popen(["killSalomeWithPort.py", "{}".format(port)])
try:
os.remove(salomePortFile)
+#!/usr/bin/env python3
+
# Copyright (C) 2020 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-#!/usr/bin/env python
-
if __name__ == '__main__':
import subprocess
from time import sleep
import sys, os
+ import tempfile
- salomeKernelDir = sys.argv[1]
- sourceDir = sys.argv[2]
- testfile = sys.argv[3]
+ testTimeout = 600
+ if len(sys.argv) > 3:
+ testTimeout = int(sys.argv[1])
+ hdffile = sys.argv[2]
+ testdatafile = sys.argv[3]
+ else:
+ hdffile = sys.argv[1]
+ testdatafile = sys.argv[2]
- portlogfile = os.getcwd() + "/.salome_port"
- testlogfile = os.getcwd() + "/test.log"
+ tempdir = tempfile.gettempdir()
+ portlogfile = tempdir + "/.salome_port"
+ testlogfile = tempdir + "/test.log"
# remove port file if any
try:
os.remove(portlogfile)
isOk = True
error = ""
- proc = subprocess.Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, "test_hdf.py", "args:" + hdffile + "," + testdatafile + "," + portlogfile + "," + testlogfile], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
try:
- proc.communicate(timeout = 600)
+ proc.communicate(timeout = testTimeout)
except TimeoutExpired:
isOk = False
proc.kill()
+++ /dev/null
-# Copyright (C) 2020 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
-#
-
-set(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
-
-# get all restricted HDF tests
-set(hdfFilesRestr "")
-if (EXISTS ${RESTRICTED_ROOT_DIR})
- file(GLOB hdfFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
-endif()
-
-# get all HDF tests from the current drectory
-file(GLOB hdfFilesCur "${CMAKE_CURRENT_SOURCE_DIR}/*.hdf")
-set(hdfFilesRestr ${hdfFilesCur} ${hdfFilesRestr})
-
-# collect test names
-set(TEST_NAMES "")
-foreach(eachFilePath ${hdfFilesRestr})
- # Strip the ".hdf" suffix
- get_filename_component(aTestName ${eachFilePath} NAME_WE)
- # Check corresponding ".py" file with reference data exists
- if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
- set(TEST_NAMES ${aTestName} ${TEST_NAMES})
- else()
- message(WARNING "File ${aTestName}.py containing reference data for ${aTestName}.hdf does not exist")
- endif()
-endforeach()
-
-# return full path to HDF file related to the given test name
-function(GET_HDF hdfFullPath testName)
- if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${testName}.hdf")
- set(${hdfFullPath} "${CMAKE_CURRENT_SOURCE_DIR}/${testName}.hdf" PARENT_SCOPE)
- elseif(EXISTS "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${testName}.hdf")
- set(${hdfFullPath} "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${testName}.hdf" PARENT_SCOPE)
- endif()
-endfunction(GET_HDF)
\ No newline at end of file
--- /dev/null
+# Copyright (C) 2020 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
+#
+
+SET(PUBLIC_TESTS @PUBLIC_TESTS@)
+
+IF(EXISTS $ENV{RESTRICTED_ROOT_DIR})
+ SET(RESTRICTED_TESTS @RESTRICTED_TESTS@)
+ELSE()
+ SET(RESTRICTED_TESTS "")
+ENDIF()