Allow for "computational electrophysiology" simulations (CompEl)
[alexxy/gromacs.git] / src / programs / mdrun / tests / moduletest.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2013,2014, 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.
8  *
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.
13  *
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.
18  *
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.
23  *
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.
31  *
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.
34  */
35 /*! \defgroup module_mdrun_integration_tests Integration test utilities
36  * \ingroup group_mdrun
37  *
38  * \brief Functionality for testing mdrun as a whole
39  */
40 #ifndef GMX_MDRUN_TESTS_MODULETEST_H
41 #define GMX_MDRUN_TESTS_MODULETEST_H
42
43 #include "testutils/integrationtests.h"
44
45 #include <gtest/gtest.h>
46 #include "testutils/cmdlinetest.h"
47
48 namespace gmx
49 {
50
51 namespace test
52 {
53
54 /*! \libinternal \brief Declares test fixture for integration tests of
55  * mdrun functionality
56  *
57  * Derived fixture classes (or individual test cases) that might have
58  * specific requirements should assert that behaviour, rather than
59  * hard-code the requirements. A test that (for example) can't run
60  * with more than one thread should report that as a diagnostic, so the
61  * person running the test (or designing the test harness) can get
62  * feedback on what tests need what conditions without having to read
63  * the code of lots of tests.
64  *
65  * The setup phase creates various temporary files for input and
66  * output that are common for mdrun tests, using the file manager
67  * object of the parent class. Individual tests should create any
68  * extra filenames similarly, so that the test users's current working
69  * directory does not get littered with files left over from all
70  * manner of tests.
71  *
72  * Specifying the execution context (such as numbers of threads and
73  * processors) is normally sensible to specify from the test harness
74  * (i.e. when CMake/CTest/the user runs a test executable), because
75  * only there is information about the hardware available. The default
76  * values for such context provided in test fixtures for mdrun should
77  * mirror the defaults for mdrun, but currently mdrun.c hard-codes
78  * those in a gmx_hw_opt_t.
79  *
80  * Any method in this class may throw std::bad_alloc if out of memory.
81  *
82  * \ingroup module_mdrun_integration_tests
83  */
84 class MdrunTestFixture : public IntegrationTestFixture
85 {
86     protected:
87         MdrunTestFixture();
88         virtual ~MdrunTestFixture();
89
90         //! Use an empty .mdp file as input to grompp
91         void useEmptyMdpFile();
92         //! Use a string as -f input to grompp
93         void useStringAsMdpFile(const char *mdpString);
94         //! Use a string as -f input to grompp
95         void useStringAsMdpFile(const std::string &mdpString);
96         //! Use a string as -n input to grompp
97         void useStringAsNdxFile(const char *ndxString);
98         //! Use a standard .top and .gro file as input to grompp
99         void useTopGroAndNdxFromDatabase(const char *name);
100         //! Calls grompp to prepare for the mdrun test
101         int callGrompp();
102         //! Calls grompp (on this rank) to prepare for the mdrun test
103         int callGromppOnThisRank();
104         //! Calls mdrun for testing with a customized command line
105         int callMdrun(const CommandLine &callerRef);
106         /*! \brief Convenience wrapper for calling mdrun for testing
107          * with default command line */
108         int callMdrun();
109
110         //@{
111         /*! \name Names for frequently used grompp and mdrun output files
112          *
113          * These strings can be set to point to files present in the
114          * source tree, or to temporary files created for the test
115          * fixture. In the latter case,
116          * IntegrationTestFixture::fileManager_ should be used to fill
117          * these strings with paths to files, so that they are created
118          * in a temporary directory and (by default behaviour of
119          * TestFileManager) deleted when the test is complete.
120          */
121         std::string topFileName;
122         std::string groFileName;
123         std::string fullPrecisionTrajectoryFileName;
124         std::string reducedPrecisionTrajectoryFileName;
125         std::string groOutputFileName;
126         std::string ndxFileName;
127         std::string mdpInputFileName;
128         std::string mdpOutputFileName;
129         std::string tprFileName;
130         std::string logFileName;
131         std::string edrFileName;
132         std::string cptFileName;
133         std::string swapFileName;
134         int         nsteps;
135         //@}
136 };
137
138 } // namespace test
139 } // namespace gmx
140
141 #endif