From: M. Eric Irrgang Date: Mon, 11 Oct 2021 09:31:02 +0000 (+0000) Subject: Normalize API tests. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=5464bff68dab266ce54f7964252da0375c984bb5;p=alexxy%2Fgromacs.git Normalize API tests. Make the gmxapi tests look more like the other tests. * Consistently use the test fixture based on the MDRun test fixture. * Move gmxapi tests to the `api/` directory now that the infrastructure allows for the move. Establishes consistency with the nblib file locations. --- diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 19403e054f..e54fc06202 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -54,6 +54,13 @@ else() endif() option(GMXAPI "Install GROMACS API." ${_GMXAPI_DEFAULT}) if (GMXAPI) + if(NOT ${BUILD_SHARED_LIBS}) + # Note: this conditional should check for the existence of a libgromacs target supporting PIC + # using the POSITION_INDEPENDENT_CODE property, but for now the only facility we have is the global + # variable, BUILD_SHARED_LIBS. + # TODO: gmxapi should gracefully build for dynamic linking or static linking for PIC or without. + message(FATAL_ERROR "GMXAPI requires position-independent code. Set -DGMXAPI=OFF or -DBUILD_SHARED_LIBS=ON.") + endif() add_subdirectory(gmxapi) endif() diff --git a/api/gmxapi/cpp/CMakeLists.txt b/api/gmxapi/cpp/CMakeLists.txt index 1e07928a83..1d01f7ebc5 100644 --- a/api/gmxapi/cpp/CMakeLists.txt +++ b/api/gmxapi/cpp/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by +# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. @@ -139,3 +139,8 @@ install( add_library(gmxapi-detail INTERFACE) target_include_directories(gmxapi-detail INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +if (BUILD_TESTING AND GMX_BUILD_UNITTESTS) + add_subdirectory(tests) + add_subdirectory(workflow/tests) +endif() diff --git a/src/api/cpp/tests/.clang-tidy b/api/gmxapi/cpp/tests/.clang-tidy similarity index 100% rename from src/api/cpp/tests/.clang-tidy rename to api/gmxapi/cpp/tests/.clang-tidy diff --git a/src/api/cpp/tests/CMakeLists.txt b/api/gmxapi/cpp/tests/CMakeLists.txt similarity index 98% rename from src/api/cpp/tests/CMakeLists.txt rename to api/gmxapi/cpp/tests/CMakeLists.txt index 66380fd929..6d3a7eccd9 100644 --- a/src/api/cpp/tests/CMakeLists.txt +++ b/api/gmxapi/cpp/tests/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by +# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/context.cpp b/api/gmxapi/cpp/tests/context.cpp similarity index 88% rename from src/api/cpp/tests/context.cpp rename to api/gmxapi/cpp/tests/context.cpp index e87387151f..cd0e811777 100644 --- a/src/api/cpp/tests/context.cpp +++ b/api/gmxapi/cpp/tests/context.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -39,14 +39,11 @@ * Provides additional test coverage of template headers only used by client code. */ -#include "config.h" - -#include - #include "gromacs/utility/gmxmpi.h" #include "gmxapi/context.h" #include "gmxapi/mpi/gmxapi_mpi.h" +#include "testingconfiguration.h" namespace gmxapi @@ -58,20 +55,20 @@ namespace testing namespace { -TEST(GmxApiMpiTest, AllContext) +TEST_F(GmxApiTest, AllContext) { // Default Implicit COMM_WORLD for MPI builds. - auto context = createContext(); + EXPECT_NO_THROW(auto context = createContext()); } #if GMX_LIB_MPI -TEST(GmxApiMpiTest, NullContext) +TEST_F(GmxApiTest, NullContext) { // Explicit COMM_NULL is not supported. EXPECT_ANY_THROW(assignResource(MPI_COMM_NULL)); } -TEST(GmxApiMpiTest, MpiWorldContext) +TEST_F(GmxApiTest, MpiWorldContext) { // Note that this test is only compiled when GMX_MPI is enabled for the // build tree, so we cannot unit test the behavior of non-MPI GROMACS @@ -89,7 +86,7 @@ TEST(GmxApiMpiTest, MpiWorldContext) auto context = createContext(*resources); } -TEST(GmxApiMpiTest, MpiSplitContext) +TEST_F(GmxApiTest, MpiSplitContext) { // Explicit sub-communicator. MPI_Comm communicator = MPI_COMM_NULL; @@ -97,7 +94,7 @@ TEST(GmxApiMpiTest, MpiSplitContext) MPI_Comm_rank(MPI_COMM_WORLD, &rank); // Run each rank as a separate ensemble member. MPI_Comm_split(MPI_COMM_WORLD, rank, rank, &communicator); - auto context = createContext(*assignResource(communicator)); + EXPECT_NO_THROW(auto context = createContext(*assignResource(communicator))); } #endif diff --git a/src/api/cpp/tests/restraint.cpp b/api/gmxapi/cpp/tests/restraint.cpp similarity index 98% rename from src/api/cpp/tests/restraint.cpp rename to api/gmxapi/cpp/tests/restraint.cpp index 08ce92c084..543cab442f 100644 --- a/src/api/cpp/tests/restraint.cpp +++ b/api/gmxapi/cpp/tests/restraint.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018, by the GROMACS development team, led by + * Copyright (c) 2018,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/runner.cpp b/api/gmxapi/cpp/tests/runner.cpp similarity index 98% rename from src/api/cpp/tests/runner.cpp rename to api/gmxapi/cpp/tests/runner.cpp index cfe49d757a..fefc2547c4 100644 --- a/src/api/cpp/tests/runner.cpp +++ b/api/gmxapi/cpp/tests/runner.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/status.cpp b/api/gmxapi/cpp/tests/status.cpp similarity index 94% rename from src/api/cpp/tests/status.cpp rename to api/gmxapi/cpp/tests/status.cpp index 7b505abe68..2a389e7705 100644 --- a/src/api/cpp/tests/status.cpp +++ b/api/gmxapi/cpp/tests/status.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018, by the GROMACS development team, led by + * Copyright (c) 2018,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -34,8 +34,7 @@ */ #include "gmxapi/status.h" - -#include +#include "testingconfiguration.h" namespace gmxapi { @@ -48,7 +47,7 @@ namespace /*! * \brief Test construction and conversion of boolean success status. */ -TEST(GmxApiBasicTest, Status) +TEST_F(GmxApiTest, Status) { { auto status = gmxapi::Status(); diff --git a/src/api/cpp/tests/stopsignaler.cpp b/api/gmxapi/cpp/tests/stopsignaler.cpp similarity index 99% rename from src/api/cpp/tests/stopsignaler.cpp rename to api/gmxapi/cpp/tests/stopsignaler.cpp index 85e8f64652..35a5eabca1 100644 --- a/src/api/cpp/tests/stopsignaler.cpp +++ b/api/gmxapi/cpp/tests/stopsignaler.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018, by the GROMACS development team, led by + * Copyright (c) 2018,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/system.cpp b/api/gmxapi/cpp/tests/system.cpp similarity index 96% rename from src/api/cpp/tests/system.cpp rename to api/gmxapi/cpp/tests/system.cpp index 25a5fc38e2..93a752aba1 100644 --- a/src/api/cpp/tests/system.cpp +++ b/api/gmxapi/cpp/tests/system.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018, by the GROMACS development team, led by + * Copyright (c) 2018,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/testingconfiguration.h b/api/gmxapi/cpp/tests/testingconfiguration.h similarity index 98% rename from src/api/cpp/tests/testingconfiguration.h rename to api/gmxapi/cpp/tests/testingconfiguration.h index 1becf04088..76ba9cdd15 100644 --- a/src/api/cpp/tests/testingconfiguration.h +++ b/api/gmxapi/cpp/tests/testingconfiguration.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/tests/version.cpp b/api/gmxapi/cpp/tests/version.cpp similarity index 97% rename from src/api/cpp/tests/version.cpp rename to api/gmxapi/cpp/tests/version.cpp index 251a7ab492..5c6c4fc81c 100644 --- a/src/api/cpp/tests/version.cpp +++ b/api/gmxapi/cpp/tests/version.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -35,8 +35,6 @@ #include -#include - #include "gmxapi/version.h" #include "testingconfiguration.h" diff --git a/src/api/cpp/workflow/tests/.clang-tidy b/api/gmxapi/cpp/workflow/tests/.clang-tidy similarity index 100% rename from src/api/cpp/workflow/tests/.clang-tidy rename to api/gmxapi/cpp/workflow/tests/.clang-tidy diff --git a/src/api/cpp/workflow/tests/CMakeLists.txt b/api/gmxapi/cpp/workflow/tests/CMakeLists.txt similarity index 97% rename from src/api/cpp/workflow/tests/CMakeLists.txt rename to api/gmxapi/cpp/workflow/tests/CMakeLists.txt index 65074a7f14..4f2ff1969d 100644 --- a/src/api/cpp/workflow/tests/CMakeLists.txt +++ b/api/gmxapi/cpp/workflow/tests/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of the GROMACS molecular simulation package. # -# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by +# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, # and including many others, as listed in the AUTHORS file in the # top-level source directory and at http://www.gromacs.org. diff --git a/src/api/cpp/workflow/tests/workflow.cpp b/api/gmxapi/cpp/workflow/tests/workflow.cpp similarity index 94% rename from src/api/cpp/workflow/tests/workflow.cpp rename to api/gmxapi/cpp/workflow/tests/workflow.cpp index f3210b2d50..2844680c36 100644 --- a/src/api/cpp/workflow/tests/workflow.cpp +++ b/api/gmxapi/cpp/workflow/tests/workflow.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -67,7 +67,7 @@ TEST_F(GmxApiTest, BuildApiWorkflowImpl) EXPECT_EQ(impl.size(), 1); // Create workflow container - gmxapi::Workflow work{ std::move(impl) }; + EXPECT_NO_THROW(gmxapi::Workflow work{ std::move(impl) }); } //! Create from create() method(s) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d6184dfd1..3358696a51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,7 +106,6 @@ endif() add_subdirectory(gromacs) add_subdirectory(programs) -add_subdirectory(api) # Configure header files with configuration-specific values. This step # should follow all introspection e.g. looking for headers and diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt deleted file mode 100644 index 0206ba1b3d..0000000000 --- a/src/api/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# -# This file is part of the GROMACS molecular simulation package. -# -# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by -# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, -# and including many others, as listed in the AUTHORS file in the -# top-level source directory and at http://www.gromacs.org. -# -# GROMACS 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. -# -# GROMACS 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 GROMACS; if not, see -# http://www.gnu.org/licenses, or write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# If you want to redistribute modifications to GROMACS, please -# consider that scientific software is very special. Version -# control is crucial - bugs must be traceable. We will be happy to -# consider code for inclusion in the official distribution, but -# derived work must not be called official GROMACS. Details are found -# in the README & COPYING files - if they are missing, get the -# official version at http://www.gromacs.org. -# -# To help us fund GROMACS development, we humbly ask that you cite -# the research papers on the package. Check out http://www.gromacs.org. - -# Activate targets for new C++ API components and docs. -if (GMXAPI) - if(NOT ${BUILD_SHARED_LIBS}) - # Note: this conditional should check for the existence of a libgromacs target supporting PIC - # using the POSITION_INDEPENDENT_CODE property, but for now the only facility we have is the global - # variable, BUILD_SHARED_LIBS. - # TODO: gmxapi should gracefully build for dynamic linking or static linking for PIC or without. - message(FATAL_ERROR "GMXAPI requires position-independent code. Set -DGMXAPI=OFF or -DBUILD_SHARED_LIBS=ON.") - endif() - add_subdirectory(cpp) -endif() - diff --git a/src/api/cpp/CMakeLists.txt b/src/api/cpp/CMakeLists.txt deleted file mode 100644 index fbeb3057d8..0000000000 --- a/src/api/cpp/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# -# This file is part of the GROMACS molecular simulation package. -# -# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by -# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, -# and including many others, as listed in the AUTHORS file in the -# top-level source directory and at http://www.gromacs.org. -# -# GROMACS 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. -# -# GROMACS 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 GROMACS; if not, see -# http://www.gnu.org/licenses, or write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# If you want to redistribute modifications to GROMACS, please -# consider that scientific software is very special. Version -# control is crucial - bugs must be traceable. We will be happy to -# consider code for inclusion in the official distribution, but -# derived work must not be called official GROMACS. Details are found -# in the README & COPYING files - if they are missing, get the -# official version at http://www.gromacs.org. -# -# To help us fund GROMACS development, we humbly ask that you cite -# the research papers on the package. Check out http://www.gromacs.org. - -if(BUILD_TESTING) - add_subdirectory(tests) - add_subdirectory(workflow/tests) -endif()