From bdb0828896c55b1428ffde02c6c26f44f5602a39 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Thu, 16 May 2019 10:06:06 +0200 Subject: [PATCH] Bug fix: Constraints tests are not instantiated with CUDA If the tests initialization macros is called with ValuesIn function, the container provided should be filled. In the current version, it is filled in the test SetUp function, after the macros is processed. As a result, the empty container is used in instantiation and no test are run. Only CUDA-enabled builds are affected. Change-Id: Ia2f38c9908d4b7d4277d282c01781b278eeeead0 --- src/gromacs/mdlib/tests/constr.cpp | 47 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/gromacs/mdlib/tests/constr.cpp b/src/gromacs/mdlib/tests/constr.cpp index e922d266aa..f7f211e7b4 100644 --- a/src/gromacs/mdlib/tests/constr.cpp +++ b/src/gromacs/mdlib/tests/constr.cpp @@ -409,12 +409,23 @@ struct ConstraintsTestData typedef std::tuple ConstraintsTestParameters; /*! \brief Names of all availible algorithms - * - * Constructed from the algorithms_ field of the test class. - * Used as the list of values of second parameter in ConstraintsTestParameters. */ static std::vector algorithmsNames; +/*! \brief Method that fills and returns algorithmNames to the test macros. + * + */ +static std::vector getAlgorithmsNames() +{ + algorithmsNames.emplace_back("SHAKE"); + algorithmsNames.emplace_back("LINCS"); + std::string errorMessage; + if (GMX_GPU == GMX_GPU_CUDA && canDetectGpus(&errorMessage)) + { + algorithmsNames.emplace_back("LINCS_CUDA"); + } + return algorithmsNames; +} /*! \brief Test fixture for constraints. * @@ -473,18 +484,8 @@ class ConstraintsTest : public ::testing::TestWithParam(testData->numAtoms_, testData->ir_.nLincsIter, testData->ir_.nProjOrder); @@ -1160,17 +1167,9 @@ TEST_P(ConstraintsTest, TriangleOfConstraints){ } -#if GMX_GPU == GMX_GPU_CUDA -INSTANTIATE_TEST_CASE_P(WithParameters, ConstraintsTest, - ::testing::Combine(::testing::Values("PBCNone", "PBCXYZ"), - ::testing::ValuesIn(algorithmsNames))); -#endif - -#if GMX_GPU != GMX_GPU_CUDA INSTANTIATE_TEST_CASE_P(WithParameters, ConstraintsTest, ::testing::Combine(::testing::Values("PBCNone", "PBCXYZ"), - ::testing::Values("SHAKE", "LINCS"))); -#endif + ::testing::ValuesIn(getAlgorithmsNames()))); } // namespace test } // namespace gmx -- 2.11.4.GIT