From f0bbe50e335aad0e0f6460075cabf416209075c5 Mon Sep 17 00:00:00 2001 From: bruno <97033386+bruno-at-orange@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:49:37 +0200 Subject: [PATCH] Fix Unit Test framework MPI Unit Tests were actually not launched with mpi. A cherry-pick from dev fixes it --- test/UnitTests/Parallel-mpi/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/UnitTests/Parallel-mpi/CMakeLists.txt b/test/UnitTests/Parallel-mpi/CMakeLists.txt index 87a26991b..11533a1a3 100644 --- a/test/UnitTests/Parallel-mpi/CMakeLists.txt +++ b/test/UnitTests/Parallel-mpi/CMakeLists.txt @@ -12,3 +12,12 @@ target_include_directories(parallel_mpi_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(parallel_mpi_test PUBLIC ${GTEST_CFLAGS}) include(GoogleTest) gtest_discover_tests(parallel_mpi_test) + +# Add the same test in CTest framework. It allows to run the test directly with the right mpi command. The command +# "ctest --preset linux-gcc-release -L mpi" will run (depending on the mpi implementation and the core number): mpiexec +# -n 8 build/linux-gcc-release/parallel_mpi_test +add_test(NAME ctest_parallel_mpi_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} + ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + +# Add "mpi" label to the test +set_tests_properties(ctest_parallel_mpi_test PROPERTIES LABELS "mpi")