1 # Copyright (C) 2014-2022 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # get all restricted HDF tests
24 IF (EXISTS $ENV{RESTRICTED_ROOT_DIR})
25 FILE(GLOB hdfFilesRestr "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
28 # get all HDF tests from the current drectory
29 file(GLOB hdfFilesCur "${CMAKE_CURRENT_SOURCE_DIR}/*.hdf")
33 foreach(eachFilePath IN LISTS hdfFilesCur hdfFilesRestr)
34 # Strip the ".hdf" suffix
35 get_filename_component(aTestName ${eachFilePath} NAME_WE)
36 # Check corresponding ".py" file with reference data exists
37 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
38 set(TEST_NAMES ${TEST_NAMES} ${aTestName})
40 message(WARNING "File ${aTestName}.py containing reference data for ${aTestName}.hdf does not exist")
46 SET(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/HDFs")
48 SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
51 SET(RESTRICTED_TESTS "")
52 FOREACH(tfile ${TEST_NAMES})
53 SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile})
55 IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
56 SET(HDF_TEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
57 SET(PUBLIC_TESTS ${PUBLIC_TESTS} ${tfile})
58 ELSEIF(EXISTS "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
59 SET(HDF_TEST_FILE "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf")
60 SET(RESTRICTED_TESTS ${RESTRICTED_TESTS} ${tfile})
63 ADD_TEST(NAME ${TEST_NAME}
64 COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "${HDF_TEST_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py")
65 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1")
66 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};models_hdf")
67 SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT ${TIMEOUT})
70 ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf")
73 FOREACH(tfile ${TEST_NAMES})
74 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py
75 DESTINATION ${TEST_INSTALL_DIRECTORY})
76 IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf")
77 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf
78 DESTINATION ${TEST_INSTALL_DIRECTORY})
82 INSTALL(FILES CTestTestfileInstall.cmake
83 DESTINATION ${TEST_INSTALL_DIRECTORY}
84 RENAME CTestTestfile.cmake)
86 INSTALL(FILES testme.py DESTINATION ${TEST_INSTALL_DIRECTORY}
87 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
88 GROUP_READ GROUP_EXECUTE
89 WORLD_READ WORLD_EXECUTE)
90 FILE(COPY test_hdf.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
91 INSTALL(FILES test_hdf.py DESTINATION ${TEST_INSTALL_DIRECTORY}
92 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
93 GROUP_READ GROUP_EXECUTE
94 WORLD_READ WORLD_EXECUTE)
95 CONFIGURE_FILE(tests.set.in ${CMAKE_CURRENT_BINARY_DIR}/tests.set @ONLY)
96 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})