]> SALOME platform Git repositories - tools/paravisaddons_common.git/commitdiff
Salome HOME
[Test] Adding test for SerafinReader
authorYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Tue, 30 Mar 2021 12:29:03 +0000 (14:29 +0200)
committerYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Wed, 12 May 2021 12:05:02 +0000 (14:05 +0200)
12 files changed:
CMakeLists.txt
src/CMakeLists.txt
src/CTestTestfileInstall.cmake.in [new file with mode: 0644]
src/SerafinReader/CMakeLists.txt
src/SerafinReader/Test/CMakeLists.txt [new file with mode: 0644]
src/SerafinReader/Test/CTestTestfileInstall.cmake [new file with mode: 0644]
src/SerafinReader/Test/geo_3d_dp.slf [new file with mode: 0644]
src/SerafinReader/Test/geo_dp.slf [new file with mode: 0644]
src/SerafinReader/Test/geo_dp_le.slf [new file with mode: 0644]
src/SerafinReader/Test/geo_sp.slf [new file with mode: 0644]
src/SerafinReader/Test/geo_sp_le.slf [new file with mode: 0644]
src/SerafinReader/Test/test_SerafinReader.py [new file with mode: 0644]

index f1b87801d688edcd485d355d59e0141c8cefa4db..957c769918347aa88ec683306234ace36f9bc7fe 100644 (file)
@@ -77,6 +77,7 @@ FIND_PACKAGE(SalomeParaView REQUIRED)
 # ====================
 SALOME_XVERSION(${PROJECT_NAME})
 SALOME_CONFIGURE_FILE(PARAVISADDONS_version.h.in PARAVISADDONS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
+OPTION(PARAVISADDONS_COMMON_BUILD_TESTS "Build PARAVISADDONS_COMMON tests." ON)
 
 # Sources
 # ========
index 080ef8049cd1332cfcd5559de71cf329182cbbff..cf8e98b48f7f48acebe46818e62a7a439e4a6a0d 100644 (file)
@@ -20,6 +20,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake files")
+SET(PARAVISADDONS_COMMON_INSTALL_TESTS tests CACHE PATH "Install path: PARAVISADDONS_COMMON tests")
 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
   INCLUDE(SalomeMacros)
@@ -70,3 +71,8 @@ ADD_SUBDIRECTORY(ElectromagnetismVecteur)
 ADD_SUBDIRECTORY(ElectromagnetismStreamTraceur)
 ADD_SUBDIRECTORY(ElectromagnetismFluxDisc)
 ADD_SUBDIRECTORY(ElectromagnetismRotation)
+
+
+# Tests
+configure_file(CTestTestfileInstall.cmake.in "CTestTestfileST.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileST.cmake DESTINATION ${PARAVISADDONS_COMMON_INSTALL_TESTS} RENAME CTestTestfile.cmake)
diff --git a/src/CTestTestfileInstall.cmake.in b/src/CTestTestfileInstall.cmake.in
new file mode 100644 (file)
index 0000000..0c82b08
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2015-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(COMPONENT_NAME PARAVISADDONS_COMMON)
+SET(TIMEOUT        120)
+
+SUBDIRS(SerafinReader)
+SUBDIRS(ElectromagnetismFluxDisc)
+SUBDIRS(ElectromagnetismRotation)
+SUBDIRS(ElectromagnetismStreamTraceur)
+SUBDIRS(ElectromagnetismVecteur)
index bbbc3e919c68b2bcd3e4521ef50a45451add024d..baef9fba8d0bc255f402fea3da0f01c3687207c2 100644 (file)
@@ -21,6 +21,10 @@ cmake_minimum_required(VERSION 3.8)
 project(SerafinReader)
 find_package(ParaView REQUIRED)
 
+IF(PARAVISADDONS_COMMON_BUILD_TESTS)
+  ADD_SUBDIRECTORY(Test)
+ENDIF(PARAVISADDONS_COMMON_BUILD_TESTS)
+
 include(GNUInstallDirs)
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
diff --git a/src/SerafinReader/Test/CMakeLists.txt b/src/SerafinReader/Test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cc8821a
--- /dev/null
@@ -0,0 +1,44 @@
+# Copyright (C) 2012-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
+#
+# Author : Yoann Audouin (EDF)
+
+SET(test_SerafinReader_src
+  geo_3d_dp.slf
+  geo_dp.slf
+  geo_dp_le.slf
+  geo_sp.slf
+  geo_sp_le.slf
+  test_SerafinReader.py
+  )
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+ADD_TEST(SerafinReader python test_SerafinReader.py)
+SET_TESTS_PROPERTIES(SerafinReader PROPERTIES ENVIRONMENT "${tests_env}")
+
+#INSTALL(TARGETS test_SerafinReader DESTINATION ${PARAVISADDONS_COMMON_INSTALL_BINS})
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${PARAVISADDONS_COMMON_INSTALL_TESTS}/SerafinReader)
+INSTALL(FILES ${test_SerafinReader_src} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+        DESTINATION ${TEST_INSTALL_DIRECTORY}
+        RENAME CTestTestfile.cmake)
diff --git a/src/SerafinReader/Test/CTestTestfileInstall.cmake b/src/SerafinReader/Test/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..b6bc57c
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2015-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(TEST_NAMES
+  test_SerafinReader
+)
+
+FOREACH(tfile ${TEST_NAMES})
+  SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+  ADD_TEST(${TEST_NAME} python ${tfile}.py)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+    LABELS "${COMPONENT_NAME}"
+    TIMEOUT ${TIMEOUT}
+    )
+ENDFOREACH()
diff --git a/src/SerafinReader/Test/geo_3d_dp.slf b/src/SerafinReader/Test/geo_3d_dp.slf
new file mode 100644 (file)
index 0000000..a002a47
Binary files /dev/null and b/src/SerafinReader/Test/geo_3d_dp.slf differ
diff --git a/src/SerafinReader/Test/geo_dp.slf b/src/SerafinReader/Test/geo_dp.slf
new file mode 100644 (file)
index 0000000..2808358
Binary files /dev/null and b/src/SerafinReader/Test/geo_dp.slf differ
diff --git a/src/SerafinReader/Test/geo_dp_le.slf b/src/SerafinReader/Test/geo_dp_le.slf
new file mode 100644 (file)
index 0000000..719682e
Binary files /dev/null and b/src/SerafinReader/Test/geo_dp_le.slf differ
diff --git a/src/SerafinReader/Test/geo_sp.slf b/src/SerafinReader/Test/geo_sp.slf
new file mode 100644 (file)
index 0000000..00b2bbb
Binary files /dev/null and b/src/SerafinReader/Test/geo_sp.slf differ
diff --git a/src/SerafinReader/Test/geo_sp_le.slf b/src/SerafinReader/Test/geo_sp_le.slf
new file mode 100644 (file)
index 0000000..806cbb9
Binary files /dev/null and b/src/SerafinReader/Test/geo_sp_le.slf differ
diff --git a/src/SerafinReader/Test/test_SerafinReader.py b/src/SerafinReader/Test/test_SerafinReader.py
new file mode 100644 (file)
index 0000000..a557ff4
--- /dev/null
@@ -0,0 +1,39 @@
+from paraview.simple import *
+from vtk.util import numpy_support
+import numpy as np
+
+paraview.simple._DisableFirstRenderCameraReset()
+
+# Normal single precision file
+reader = SerafinReader(FileName='geo_sp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)
+# Checking that fields THING X THING Y are merged into THING *
+list_var = [reader_ds.GetPointData().GetArrayName(i).strip() for i in range(reader_ds.GetPointData().GetNumberOfArrays())]
+assert("THING *" in list_var)
+assert("THING X" not in list_var)
+assert("THING OTHER" in list_var)
+# Checking that fields VELOCITY U, VELOCITY V are merged into VELOCITY *
+assert("VELOCITY *" in list_var)
+assert("VELOCITY U" not in list_var)
+assert("VELOCITY STUFF" in list_var)
+# Checking that VELOCITY has 3 components shoulb be on 0
+assert(reader_ds.GetPointData().GetArray(0).GetNumberOfComponents() == 3)
+
+# Simple read of Litte Endian file (Would crash if issue in the plugin)
+reader = SerafinReader(FileName='geo_sp_le.slf')
+# Simple read of Litte Endian file (Would crash if issue in the plugin)
+reader = SerafinReader(FileName='geo_dp_le.slf')
+
+# Normal double precision file
+reader = SerafinReader(FileName='geo_dp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)
+# Checking that values are properly read
+data = numpy_support.vtk_to_numpy(reader_ds.GetPointData().GetArray(0))
+assert(np.all(data <= 1e-8))
+
+# 3d mesh
+reader = SerafinReader(FileName='geo_3d_dp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)