Commit 169f210a authored by GILLES Sebastien's avatar GILLES Sebastien

#1248 Extend integration test script to take into account Catch tests (which...

#1248 Extend integration test script to take into account Catch tests (which don't take Lua file as input in command line).
parent 7c8114df
......@@ -113,10 +113,14 @@ class CheckMoReFEM:
for target in target_list:
model_name = target.executable
if target.lua_file_list:
target_list_full_path = (os.path.join(self.__morefem_path, item) for item in target.lua_file_list)
target_list_full_path = (os.path.join(self.__morefem_path, item) for item in target.lua_file_list)
self.TestModel(model_name, target_list_full_path, target.do_call_ensight_output, target.Nproc, target.is_sequential)
else:
self.CatchTest(model_name, target.Nproc, target.is_sequential)
self.TestModel(model_name, target_list_full_path, target.do_call_ensight_output, target.Nproc, target.is_sequential)
def __del__(self):
......@@ -198,6 +202,32 @@ class CheckMoReFEM:
self.__RefreshLogFiles()
def CatchTest(self, model_name, Nproc, is_sequential):
"""
\param[in] Nproc Number of processors to deal with in parallel. Put 0 or 1 if parallel is not relevant for the model.
"""
self.__log.write("=============================================\n")
self.__log.write("Compiling and running model {model}\n".format(model = model_name))
self.__log.write("=============================================\n")
if self.__Compile(model_name, False):
if is_sequential:
self.__SequentialRun(model_name, None, False)
# Parallel case: just run, as the current comparison by diffs wouldn't do for parallel case.
if Nproc > 1:
self.__ParallelRun(model_name, None, False, Nproc)
self.__log.write("\n\n")
# Steps to ensure the log may be consulted during the test process.
self.__RefreshLogFiles()
def __Compile(self, model_name, do_call_ensight_output):
os.chdir(self.__cmake_build_dir)
......@@ -229,9 +259,14 @@ class CheckMoReFEM:
def __SequentialRun(self, model_name, lua_file, do_call_ensight_output):
cmd = (os.path.join(self.__cmake_build_dir, "Sources", model_name),
"--input_parameters",
lua_file)
if lua_file:
cmd = (os.path.join(self.__cmake_build_dir, "Sources", model_name),
"-i",
lua_file)
with_lua = " with {}".format(lua_file)
else:
cmd = (os.path.join(self.__cmake_build_dir, "Sources", model_name), )
with_lua = ""
self.__PrintCmd(cmd)
......@@ -239,10 +274,10 @@ class CheckMoReFEM:
execution.communicate()
if execution.returncode is not 0:
self.__log.write("\tExecution with {lua} failed!\n".format(lua = lua_file))
self.__log.write("\tExecution failed{with_lua}!\n".format(with_lua = with_lua))
return False
else:
self.__log.write("\tSuccessful sequential run with {lua}.\n".format(lua = lua_file))
self.__log.write("\tSuccessful sequential run{with_lua}.\n".format(with_lua = with_lua))
if do_call_ensight_output:
self.__EnsightOutput(model_name, lua_file)
......@@ -253,7 +288,7 @@ class CheckMoReFEM:
def __EnsightOutput(self, model_name, lua_file):
cmd = (os.path.join(self.__cmake_build_dir, "Sources", "{}EnsightOutput".format(model_name)),
"--input_parameters",
"-i",
lua_file)
self.__PrintCmd(cmd)
......@@ -271,19 +306,31 @@ class CheckMoReFEM:
def __ParallelRun(self, model_name, lua_file, do_call_ensight_output, Nproc):
cmd = (os.path.join(self.__mpi_dir, "bin", "mpirun"),
"-np",
str(Nproc),
os.path.join(self.__cmake_build_dir, "Sources", model_name),
"--input_parameters",
lua_file)
if lua_file:
cmd = (os.path.join(self.__mpi_dir, "bin", "mpirun"),
"-np",
str(Nproc),
os.path.join(self.__cmake_build_dir, "Sources", model_name),
"--input_parameters",
lua_file)
lua_filename = os.path.split(lua_file)[1]
assert(lua_filename.endswith(".lua"))
lua_filename = lua_filename[:-4]
lua_filename = os.path.split(lua_file)[1]
assert(lua_filename.endswith(".lua"))
lua_filename = "_{}".format(lua_filename[:-4])
with_lua = " with {}".format(lua_file)
else:
cmd = (os.path.join(self.__mpi_dir, "bin", "mpirun"),
"-np",
str(Nproc),
os.path.join(self.__cmake_build_dir, "Sources", model_name))
lua_filename = ""
with_lua = ""
script_file = os.path.join(self.__work_dir,
"mpi_{model}_{lua}.sh".format(model = model_name, lua = lua_filename))
"mpi_{model}{lua}.sh".format(model = model_name, lua = lua_filename))
with open(script_file, 'w') as FILE:
FILE.write("#! /bin/zsh\n")
......@@ -297,10 +344,10 @@ class CheckMoReFEM:
execution.communicate()
if execution.returncode is not 0:
self.__log.write("\tParallel execution with {lua} failed!\n".format(lua = lua_file))
self.__log.write("\tParallel execution{with_lua} failed!\n".format(with_lua = with_lua))
return False
else:
self.__log.write("\tSuccessful parallel run with {lua}.\n".format(lua = lua_file))
self.__log.write("\tSuccessful parallel run{with_lua}.\n".format(with_lua = with_lua))
if do_call_ensight_output:
self.__EnsightOutput(model_name, lua_file)
......@@ -369,7 +416,7 @@ if __name__ == "__main__":
morefem_path = os.path.join("/Users", os.environ['USER'], "Codes", "MoReFEM", "CoreLibrary")
cases = ('clang_debug', 'clang_release', 'llvm-clang_debug')
for case in cases:
......
......@@ -81,14 +81,10 @@ def TestTargetList():
TestTarget('MoReFEMTestFromVertexMatching', vertex_matching_operator_lua_list),
# TestTarget('test_param_at_dof', \
# ('Sources/Test/Parameter/AtDof/demo_input_test_at_dof_parameter.lua', )),
TestTarget('MoReFEMTestParameterTimeDependancy', \
TestTarget('MoReF EMTestParameterTimeDependancy', \
('Sources/Test/Parameter/TimeDependency/demo_input_test_parameter_time_dependency.lua', ),
Nproc = 0),
TestTarget('MoReFEMTestOperatorTestFunctions', \
('Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_1D.lua', \
'Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_2D.lua', \
'Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_3D.lua'), \
Nproc = 2),
TestTarget('MoReFEMTestOperatorTestFunctions', None, Nproc = 0)
)
......@@ -125,8 +121,7 @@ def TestAndModelTargetList():
ret = list(TestTargetList())
ret.extend(ModelTargetList())
return ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment