--- /dev/null
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# 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.
+#
+# 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
+#
+ADD_SUBDIRECTORY(examples)
--- /dev/null
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# 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.
+#
+# 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(EXAMPLES_TESTS
+ hs_001_telemac_cata.py
+)
+
+SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
+INSTALL(FILES ${EXAMPLES_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
--- /dev/null
+# 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(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py")
+SET(COMPONENT_NAME HYDROSOLVER)
+SET(TIMEOUT 300)
+
+SET(EXAMPLES_TESTS
+ hs_001_telemac_cata.py
+)
+
+FOREACH(tfile ${EXAMPLES_TESTS})
+ SET(TEST_NAME HYDROSOLVER_${tfile})
+ ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+ENDFOREACH()
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Modules Python
+import sys
+from os import path, listdir, system, chdir, environ, remove
+from argparse import ArgumentParser
+import shutil
+import re
+
+import salome
+from execution.telemac_cas import TelemacCas, get_dico
+
+# Adding Eficas to PYTHONPATH
+sys.path.append(environ["EFICAS_NOUVEAU_ROOT"])
+try:
+ import Telemac.prefs
+except ImportError as excp:
+ print("Add the path to eficas to PYTHONPATH")
+if hasattr(Telemac.prefs, 'encoding'):
+ # Hack pour changer le codage par defaut des strings
+ import sys
+ reload(sys)
+ sys.setdefaultencoding(prefs.encoding)
+ del sys.setdefaultencoding
+ # Fin hack
+
+HEADER = '\033[95m'
+OKBLUE = '\033[94m'
+OKGREEN = '\033[92m'
+WARNING = '\033[93m'
+FAIL = '\033[91m'
+ENDC = '\033[0m'
+BOLD = '\033[1m'
+UNDERLINE = '\033[4m'
+
+PREFIX = {'telemac2d':'t2d',
+ 'telemac3d':'t3d',
+ 'tomawac':'tom',
+ 'sisyphe':'sis',
+ 'artemis':'art',
+ 'waqtel':'waq'}
+
+def diff_cas(cas1, cas2):
+ """
+ Diff between two cases will return True if cas.get for each keyword (in
+ both files) returns the same thing
+
+ @param cas1 (TelemacCas) cas1
+ @param cas2 (TelemacCas) cas2
+
+ @returns True if identical
+ """
+
+ # Get the list of keys from cas1 and cas2
+ keys = list(cas1.values.keys())
+ keys.extend(key for key in cas2.values.keys() if key not in keys)
+
+ diff = True
+ for key in keys:
+ val1 = cas1.get(key)
+ val2 = cas2.get(key)
+ if val1 != val2:
+ diff = False
+ print("Differences for {}\n{}: {}\n{}:"\
+ .format(key,
+ path.basename(cas1.file_name),
+ val1,
+ path.basename(cas2.file_name),
+ val2,
+ ))
+
+ return diff
+
+
+def read_write_eficas(module, steering_file, eficas_steering):
+ """
+ Import a steergin file in Eficas and save it back
+
+ @param module Name of the telemac-mascaret module
+ @param steering_file Name of the steering file
+ @param eficas_file Name of the steering file written by Eficas
+ """
+ from InterfaceQT4.eficas_go import getEficasSsIhm
+ code = 'TELEMAC'
+ my_eficas = getEficasSsIhm(code='TELEMAC',labelCode=module)
+
+ handler = my_eficas.fileOpen(steering_file)
+ if not handler:
+ raise Exception(steering_file, "Eficas crashed")
+ if not handler.isJdcValid():
+ report = handler.getJdcRapport()
+ raise Exception(steering_file, report)
+
+ handler.fileSaveAs(eficas_steering)
+
+def validate_catalog(module, root_dir):
+ """
+ Validate a given Catalog for a given module
+
+ @param module Name of the module
+ @param root_dir Telemac root path
+ """
+ print(" "*2, "~> For module", module)
+ examples_dir = path.join(root_dir, 'examples', module)
+ output_dir = path.join(root_dir, 'examples', 'eficas')
+
+ telemac_dico = path.join(root_dir, 'sources', module, module+'.dico')
+
+ crashed = []
+ different = []
+ for example in sorted(listdir(examples_dir)):
+ example_dir = path.join(examples_dir, example)
+ chdir(example_dir)
+ print(" "*3, "~> In example folder ", example_dir)
+ for case in sorted(listdir(example_dir)):
+ if case.endswith('.cas') and \
+ "_reecrit" not in case and \
+ case[0:3] == PREFIX[module] and \
+ "_reecrit" not in case and \
+ "_ori" not in case:
+ # Adding lang extension (.fr for translated french case)
+ print(" "*4, "~> For test case ", case)
+ root, _ = path.splitext(case)
+
+ lang = ''
+ eficas_case = root + "_reecrit.cas"
+
+ # Import and export in eficas
+ try:
+ read_write_eficas(module, case, eficas_case)
+ except Exception as e:
+ print(e)
+ crashed.append(case)
+ print(" "*8+FAIL+"FAILED"+ENDC)
+ print(" "*8+"Crashed in eficas")
+ continue
+
+ ori_cas = TelemacCas(case, telemac_dico)
+ eficas_cas = TelemacCas(eficas_case, telemac_dico)
+
+ isdiff = diff_cas(ori_cas, eficas_cas)
+
+ if not isdiff:
+ different.append(case)
+ print(" "*8+FAIL+"FAILED"+ENDC)
+ print(" "*8+"Diff in steering case")
+ continue
+
+ # Clean up of files
+ remove(eficas_case)
+
+ # Passed the test case
+ print(" "*8+OKGREEN+"PASSED"+ENDC)
+
+ if crashed != []:
+ print("The following test in", module,
+ " crashed in eficas:", crashed)
+ if different != []:
+ print("The following test in", module,
+ " have a difference with normal run:", different)
+
+salome.salome_init()
+
+#-----------------
+#-- Eficas
+#-----------------
+
+for module in ['telemac2d', 'telemac3d']:
+ # Testing loading of catalog
+ validate_catalog(module, environ["HOMETEL"])
+