Merge branch 'release-4-6'
[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, 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
47 namespace gmx
48 {
49
50 namespace test
51 {
52
53 /*! \libinternal \brief Declares test fixture for integration tests of
54  * mdrun functionality
55  *
56  * Derived fixture classes (or individual test cases) that might have
57  * specific requirements should assert that behaviour, rather than
58  * hard-code the requirements. A test that (for example) can't run
59  * with more than one thread should report that as a diagnostic, so the
60  * person running the test (or designing the test harness) can get
61  * feedback on what tests need what conditions without having to read
62  * the code of lots of tests.
63  *
64  * The setup phase creates various temporary files for input and
65  * output that are common for mdrun tests, using the file manager
66  * object of the parent class. Individual tests should create any
67  * extra filenames similarly, so that the test users's current working
68  * directory does not get littered with files left over from all
69  * manner of tests.
70  *
71  * Specifying the execution context (such as numbers of threads and
72  * processors) is normally sensible to specify from the test harness
73  * (i.e. when CMake/CTest/the user runs a test executable), because
74  * only there is information about the hardware available. The default
75  * values for such context provided in test fixtures for mdrun should
76  * mirror the defaults for mdrun, but currently mdrun.c hard-codes
77  * those in a gmx_hw_opt_t.
78  *
79  * Any method in this class may throw std::bad_alloc if out of memory.
80  *
81  * \ingroup module_mdrun_integration_tests
82  */
83 class MdrunTestFixture : public IntegrationTestFixture
84 {
85     protected:
86         MdrunTestFixture();
87         virtual ~MdrunTestFixture();
88
89         //! Use an empty .mdp file as input to grompp
90         void useEmptyMdpFile();
91         //! Use an empty .mdp file as input to grompp
92         void useStringAsMdpFile(const char *mdpString);
93         //! Use a standard .top and .gro file as input to grompp
94         void useTopAndGroFromDatabase(const char *name);
95         //! Calls grompp to prepare for the mdrun test
96         int callGrompp();
97         //! Calls mdrun for testing
98         int callMdrun();
99
100         //@{
101         /*! \name Names for frequently used grompp and mdrun output files
102          *
103          * These strings can be set to point to files present in the
104          * source tree, or to temporary files created for the test
105          * fixture. In the latter case,
106          * IntegrationTestFixture::fileManager_ should be used to fill
107          * these strings with paths to files, so that they are created
108          * in a temporary directory and (by default behaviour of
109          * TestFileManager) deleted when the test is complete.
110          */
111         std::string topFileName;
112         std::string groFileName;
113         std::string trrFileName;
114         std::string xtcFileName;
115         std::string rerunFileName;
116         std::string mdpInputFileName;
117         std::string mdpOutputFileName;
118         std::string tprFileName;
119         std::string logFileName;
120         std::string edrFileName;
121         //@}
122 };
123
124 } // namespace test
125 } // namespace gmx
126
127 #endif