From fb9d413353f86016506f2ae4d683d32f1ce76e7c Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Tue, 30 Mar 2021 14:29:03 +0200 Subject: [PATCH] [Test] Adding test for SerafinReader --- CMakeLists.txt | 1 + src/CMakeLists.txt | 6 +++ src/CTestTestfileInstall.cmake.in | 27 +++++++++++ src/SerafinReader/CMakeLists.txt | 4 ++ src/SerafinReader/Test/CMakeLists.txt | 44 ++++++++++++++++++ .../Test/CTestTestfileInstall.cmake | 31 ++++++++++++ src/SerafinReader/Test/geo_3d_dp.slf | Bin 0 -> 1889 bytes src/SerafinReader/Test/geo_dp.slf | Bin 0 -> 1000 bytes src/SerafinReader/Test/geo_dp_le.slf | Bin 0 -> 1000 bytes src/SerafinReader/Test/geo_sp.slf | Bin 0 -> 804 bytes src/SerafinReader/Test/geo_sp_le.slf | Bin 0 -> 804 bytes src/SerafinReader/Test/test_SerafinReader.py | 39 ++++++++++++++++ 12 files changed, 152 insertions(+) create mode 100644 src/CTestTestfileInstall.cmake.in create mode 100644 src/SerafinReader/Test/CMakeLists.txt create mode 100644 src/SerafinReader/Test/CTestTestfileInstall.cmake create mode 100644 src/SerafinReader/Test/geo_3d_dp.slf create mode 100644 src/SerafinReader/Test/geo_dp.slf create mode 100644 src/SerafinReader/Test/geo_dp_le.slf create mode 100644 src/SerafinReader/Test/geo_sp.slf create mode 100644 src/SerafinReader/Test/geo_sp_le.slf create mode 100644 src/SerafinReader/Test/test_SerafinReader.py diff --git a/CMakeLists.txt b/CMakeLists.txt index f1b8780..957c769 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 # ======== diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 080ef80..cf8e98b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 index 0000000..0c82b08 --- /dev/null +++ b/src/CTestTestfileInstall.cmake.in @@ -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) diff --git a/src/SerafinReader/CMakeLists.txt b/src/SerafinReader/CMakeLists.txt index bbbc3e9..baef9fb 100644 --- a/src/SerafinReader/CMakeLists.txt +++ b/src/SerafinReader/CMakeLists.txt @@ -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 index 0000000..cc8821a --- /dev/null +++ b/src/SerafinReader/Test/CMakeLists.txt @@ -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 index 0000000..b6bc57c --- /dev/null +++ b/src/SerafinReader/Test/CTestTestfileInstall.cmake @@ -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 index 0000000000000000000000000000000000000000..a002a479884cf672171af38bb981e4dcac1b1ab9 GIT binary patch literal 1889 zcmcJN%}T>i5QVS5)#}2H;PNiJ^bOKd6AhF^Y#MD>BU(WagyIwWBtC*mm!3oK&`1)z zDcl1eGo3jzQ*LXFxm_&Zo*(VU>hE<(0gG_?-OwsoP(;+GiP8QoPtBZIo8DGoMXQS_&fIjYX^XJ)=q%d_mH#4 zI{zQ+(Z?G1)5jX`3AhAZ#Tn6|=zEOT}FDgKyNmzR}(2e8>0uRD8TaLQ8OfgqGj{2`#|^5?X=-B(wwvNN5QTkkFF; EFM%#)2mk;8 literal 0 HcmV?d00001 diff --git a/src/SerafinReader/Test/geo_dp.slf b/src/SerafinReader/Test/geo_dp.slf new file mode 100644 index 0000000000000000000000000000000000000000..2808358991f7163994a9453baecbcca35f8e6b4b GIT binary patch literal 1000 zcmds#%?g4*6ose%mTiKTvuxQLXq2W98vc>(q6~r{ke;w7=@DAC?4F!SMJ;LBh2y!- z{mvZ_8DpzWblPwEB|aX`@h;*&m#aBb-L&S6c9Qy}E(wL62inq}nO?~K@+-jPxS%HI zdcLj~S-Hs`s4q#-F=G-Cr&n}l!L zA|Z#fiRh8T9Nx+FVC6d;d1SD&sxSldD&?NInix}VNuxZ3i#fd^^UfvH^eOj9SJM$P W_(x=+uiPV{690IA2``WSKKBI5zCWJ; literal 0 HcmV?d00001 diff --git a/src/SerafinReader/Test/geo_dp_le.slf b/src/SerafinReader/Test/geo_dp_le.slf new file mode 100644 index 0000000000000000000000000000000000000000..719682ee75066624be8ea5b0c0fe6555a28834b0 GIT binary patch literal 1000 zcmd^7%?g4*7~K9lb_qJ}v14zbQJO-i_(yh&G6;e|dcvNhNATFOZ)i8Q6s2ne!+hWF z%q)lwV{99r4?BKMPRC2KkNMB=G*3zNQA+b*cFmqz4t?h;BM?9!_;?oy4^m%@u z>m^>%=NqQA;+qnKI4by}hCbUjG`HMKeN$qKSO<9Eoe*yW#@eJ~Vjj2~5xYcu(+&|i zoXy0H9PXjL+zhYWp~xeH&MM#zo+463?CMMJVt)ut6=c41BJ~#8BbBMh;2)8|T;C(z NnKpYr^ULWUa!dCENcIV*j<1%a%vS-1GS?_aX2*5iV literal 0 HcmV?d00001 diff --git a/src/SerafinReader/Test/geo_sp_le.slf b/src/SerafinReader/Test/geo_sp_le.slf new file mode 100644 index 0000000000000000000000000000000000000000..806cbb9061d6f8a25a9cdbc604d1e0f743cd8e04 GIT binary patch literal 804 zcmd6j%?g4*6ose%mTiKTvuxQLScIk!DmF^Ci!um;KzaZlEqb!fF+&X{Y1M(_y));# zSJ4$h?4rwYFK_Yrbd3*@{8<~_TNsutUF;mfeVAe|;Xq$IOG|~)uX)8M7c}HH$~TM( zHruC6%U;QC1(02pxUeDTC{y>US?rs_E%=+rke$Gffe>xfF z&M{~06?(GoGb`sg!<}_vmgk9v;~Yl4!--bTk)$H`Vwv+>DAs&edR2N<@5+&X$e$7) BI~xE1 literal 0 HcmV?d00001 diff --git a/src/SerafinReader/Test/test_SerafinReader.py b/src/SerafinReader/Test/test_SerafinReader.py new file mode 100644 index 0000000..a557ff4 --- /dev/null +++ b/src/SerafinReader/Test/test_SerafinReader.py @@ -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) -- 2.39.2