From 41031eecd750d91cd186e4041dcaa78876314b12 Mon Sep 17 00:00:00 2001 From: "M. Eric Irrgang" Date: Fri, 11 Sep 2020 16:47:56 +0300 Subject: [PATCH] Refine the CMakeLists.txt for MPI gmxapi tests. Exclude tests when GMX_MPI is not set. Normalize test working directory. --- src/api/cpp/tests/CMakeLists.txt | 51 ++++++++++++++--------- src/api/cpp/workflow/tests/CMakeLists.txt | 37 ++++++++++------ 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/src/api/cpp/tests/CMakeLists.txt b/src/api/cpp/tests/CMakeLists.txt index e674ac44e6..ee3f1ed8b5 100644 --- a/src/api/cpp/tests/CMakeLists.txt +++ b/src/api/cpp/tests/CMakeLists.txt @@ -79,26 +79,37 @@ set_tests_properties(GmxapiExternalInterfaceTests PROPERTIES # # Test public interface with MPI. # +# gmxapi is expected to work whether or not GROMACS was built with MPI (or tMPI) +# but we don't assume that MPI is available to the build tree or testing tools +# unless CMake was configured with MPI. +# +# For MPI-enabled testing of gmxapi clients using non-MPI-enabled GROMACS, we +# defer testing to the Python gmxapi client package tests. +# +if (GMX_MPI) + gmx_add_gtest_executable(gmxapi-mpi-test MPI + CPP_SOURCE_FILES + restraint.cpp + status.cpp + system.cpp + version.cpp + # pseudo-library for code for mdrun + $ + ) + if(NOT GMX_GPU_OPENCL) + # GPU resources may not be properly reinitialized between simulations in + # the same process. + # TODO: include this with the other test sources once the issue is resolved + # Ref https://gitlab.com/gromacs/gromacs/-/issues/2689 + target_sources(gmxapi-mpi-test PRIVATE runner.cpp stopsignaler.cpp) + endif() -gmx_add_gtest_executable(gmxapi-mpi-test MPI - CPP_SOURCE_FILES - restraint.cpp - status.cpp - system.cpp - version.cpp - # pseudo-library for code for mdrun - $ - ) -if(NOT GMX_GPU_OPENCL) - # GPU resources may not be properly reinitialized between simulations in - # the same process. - # TODO: include this with the other test sources once the issue is resolved - # Ref https://gitlab.com/gromacs/gromacs/-/issues/2689 - target_sources(gmxapi-mpi-test PRIVATE runner.cpp stopsignaler.cpp) -endif() + target_include_directories(gmxapi-mpi-test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}) + target_link_libraries(gmxapi-mpi-test PRIVATE Gromacs::gmxapi gmxapi-testsupport mdrun_test_infrastructure) -target_include_directories(gmxapi-mpi-test PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(gmxapi-mpi-test PRIVATE Gromacs::gmxapi gmxapi-testsupport mdrun_test_infrastructure) + gmx_register_gtest_test(GmxapiMpiTests gmxapi-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS) -gmx_register_gtest_test(GmxapiMpiTests gmxapi-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS) + set_tests_properties(GmxapiMpiTests PROPERTIES + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endif () diff --git a/src/api/cpp/workflow/tests/CMakeLists.txt b/src/api/cpp/workflow/tests/CMakeLists.txt index edf78badb5..65074a7f14 100644 --- a/src/api/cpp/workflow/tests/CMakeLists.txt +++ b/src/api/cpp/workflow/tests/CMakeLists.txt @@ -57,19 +57,30 @@ set_tests_properties(GmxapiInternalInterfaceTests PROPERTIES # # Test with MPI. # +# gmxapi is expected to work whether or not GROMACS was built with MPI (or tMPI) +# but we don't assume that MPI is available to the build tree or testing tools +# unless CMake was configured with MPI. +# +# For MPI-enabled testing of gmxapi clients using non-MPI-enabled GROMACS, we +# defer testing to the Python gmxapi client package tests. +# +if (GMX_MPI) + gmx_add_gtest_executable(workflow-details-mpi-test MPI + CPP_SOURCE_FILES + workflow.cpp + # pseudo-library for code for mdrun + $ + ) -gmx_add_gtest_executable(workflow-details-mpi-test MPI - CPP_SOURCE_FILES - workflow.cpp - # pseudo-library for code for mdrun - $ -) + target_link_libraries(workflow-details-mpi-test + PRIVATE + Gromacs::gmxapi + gmxapi-detail + gmxapi-testsupport + mdrun_test_infrastructure) -target_link_libraries(workflow-details-mpi-test - PRIVATE - Gromacs::gmxapi - gmxapi-detail - gmxapi-testsupport - mdrun_test_infrastructure) + gmx_register_gtest_test(GmxapiInternalsMpiTests workflow-details-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS) -gmx_register_gtest_test(GmxapiInternalsMpiTests workflow-details-mpi-test MPI_RANKS 2 OPENMP_THREADS 2 INTEGRATION_TEST IGNORE_LEAKS) + set_tests_properties(GmxapiInternalsMpiTests PROPERTIES + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endif () -- 2.22.0