2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \defgroup module_mdrun_integration_tests Integration test utilities
36 * \ingroup group_mdrun
38 * \brief Functionality for testing mdrun as a whole
42 * Declares test fixtures for general mdrun functionality.
44 * \author Mark Abraham <mark.j.abraham@gmail.com>
45 * \ingroup module_mdrun_integration_tests
47 #ifndef GMX_MDRUN_TESTS_MODULETEST_H
48 #define GMX_MDRUN_TESTS_MODULETEST_H
50 #include <gtest/gtest.h>
52 #include "testutils/cmdlinetest.h"
53 #include "testutils/integrationtests.h"
62 * \brief Helper object for running grompp and mdrun in
63 * integration tests of mdrun functionality
65 * Objects of this class are intended to be owned by
66 * IntegrationTestFixture objects, and an IntegrationTestFixture
67 * object might own more than one SimulationRunner.
69 * The setup phase creates various temporary files for input and
70 * output that are common for mdrun tests, using the file manager
71 * object of the fixture that owns this object. Individual tests
72 * should create any extra filenames similarly, so that the test
73 * users's current working directory does not get littered with files
74 * left over from tests.
76 * Any method in this class may throw std::bad_alloc if out of memory.
78 * By default, the convenience methods callGrompp() and callMdrun()
79 * just prepare and run a default call to mdrun. If there is a need to
80 * customize the command-line for grompp or mdrun (e.g. to invoke
81 * -maxwarn n, or -reprod), then make a CommandLine object with the
82 * appropriate flags and pass that into the routines that accept such.
84 * \ingroup module_mdrun_integration_tests
86 class SimulationRunner
89 /*! \brief Constructor, which establishes the fixture that
90 * will own each object */
91 explicit SimulationRunner(IntegrationTestFixture
*fixture_
);
93 //! Use an empty .mdp file as input to grompp
94 void useEmptyMdpFile();
95 //! Use a given string as input to grompp
96 void useStringAsMdpFile(const char *mdpString
);
97 //! Use a given string as input to grompp
98 void useStringAsMdpFile(const std::string
&mdpString
);
99 //! Use a string as -n input to grompp
100 void useStringAsNdxFile(const char *ndxString
);
101 //! Use a standard .top and .gro file as input to grompp
102 void useTopGroAndNdxFromDatabase(const char *name
);
103 //! Use a standard .gro file as input to grompp
104 void useGroFromDatabase(const char *name
);
105 //! Calls grompp (on rank 0, with a customized command line) to prepare for the mdrun test
106 int callGrompp(const CommandLine
&callerRef
);
107 //! Convenience wrapper for a default call to \c callGrompp
109 //! Calls grompp (on this rank, with a customized command line) to prepare for the mdrun test
110 int callGromppOnThisRank(const CommandLine
&callerRef
);
111 //! Convenience wrapper for a default call to \c callGromppOnThisRank
112 int callGromppOnThisRank();
113 //! Calls mdrun for testing with a customized command line
114 int callMdrun(const CommandLine
&callerRef
);
115 /*! \brief Convenience wrapper for calling mdrun for testing
116 * with default command line */
120 //! Provides access to the test fixture, e.g. for the TestFileManager
121 IntegrationTestFixture
*fixture_
;
124 /*! \name Names for frequently used grompp and mdrun output files
126 * These strings can be set to point to files present in the
127 * source tree, or to temporary files created for the test
128 * fixture. In the latter case,
129 * IntegrationTestFixture::fileManager_ should be used to fill
130 * these strings with paths to files, so that they are created
131 * in a temporary directory and (by default behaviour of
132 * TestFileManager) deleted when the test is complete.
134 std::string topFileName_
;
135 std::string groFileName_
;
136 std::string fullPrecisionTrajectoryFileName_
;
137 std::string reducedPrecisionTrajectoryFileName_
;
138 std::string groOutputFileName_
;
139 std::string ndxFileName_
;
140 std::string mdpInputFileName_
;
141 std::string mdpOutputFileName_
;
142 std::string tprFileName_
;
143 std::string logFileName_
;
144 std::string edrFileName_
;
145 std::string cptFileName_
;
146 std::string swapFileName_
;
152 * \brief Declares test fixture base class for
153 * integration tests of mdrun functionality
155 * Derived fixture classes (or individual test cases) that might have
156 * specific requirements should assert that behaviour, rather than
157 * hard-code the requirements. A test that (for example) can't run
158 * with more than one thread should report that as a diagnostic, so the
159 * person running the test (or designing the test harness) can get
160 * feedback on what tests need what conditions without having to read
161 * the code of lots of tests.
163 * Specifying the execution context (such as numbers of threads and
164 * processors) is normally sensible to specify from the test harness
165 * (i.e. when CMake/CTest/the user runs a test executable), because
166 * only there is information about the hardware available. The default
167 * values for such context provided in test fixtures for mdrun should
168 * mirror the defaults for mdrun, but currently mdrun.c hard-codes
169 * those in a gmx_hw_opt_t.
171 * Any method in this class may throw std::bad_alloc if out of memory.
173 * \ingroup module_mdrun_integration_tests
175 class MdrunTestFixtureBase
: public IntegrationTestFixture
178 MdrunTestFixtureBase();
179 virtual ~MdrunTestFixtureBase();
183 * \brief Declares test fixture class for integration
184 * tests of mdrun functionality that use a single call of mdrun
186 * Any method in this class may throw std::bad_alloc if out of memory.
188 * \ingroup module_mdrun_integration_tests
190 class MdrunTestFixture
: public IntegrationTestFixture
194 virtual ~MdrunTestFixture();
196 //! Helper object to manage the preparation for and call of mdrun
197 SimulationRunner runner_
;
202 * Parameterized test fixture for mdrun integration tests
204 class ParameterizedMdrunTestFixture
: public gmx::test::MdrunTestFixture
,
205 public ::testing::WithParamInterface
<const char *>