Fix #3655
[gromacs.git] / src / programs / mdrun / tests / outputfiles.cpp
blob9414b16c9f2e2659a8b53e2728627c363f1c0668
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019,2020, 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.
36 /*! \internal \file
37 * \brief
38 * Checks that expected output files are present
40 * \author Pascal Merz <pascal.merz@me.com>
41 * \ingroup module_mdrun_integration_tests
44 #include "gmxpre.h"
46 #include "gromacs/utility/path.h"
47 #include "gromacs/utility/stringutil.h"
49 #include "testutils/simulationdatabase.h"
51 #include "moduletest.h"
53 namespace gmx
55 namespace test
57 namespace
60 /*! \brief Test fixture base for presence of output files
62 * This test checks that some expected output files are actually written
63 * in a very simple mdrun call. Currently, it tests for the presence of
64 * full precision trajectory (.trr), log file (.log), energy trajectory (.edr),
65 * final configuration (.gro) and checkpoint file (.cpt).
67 * The test only checks whether the files are existing, it does not check
68 * their contents.
70 using OutputFilesTestParams = std::tuple<std::string, std::string>;
71 class OutputFiles : public MdrunTestFixture, public ::testing::WithParamInterface<OutputFilesTestParams>
75 TEST_P(OutputFiles, FilesArePresent)
77 auto params = GetParam();
78 auto simulationName = std::get<0>(params);
79 auto integrator = std::get<1>(params);
81 SCOPED_TRACE(
82 formatString("Checking for presence of expected output files using "
83 "simulation '%s' with integrator '%s'",
84 simulationName.c_str(), integrator.c_str()));
86 // Prepare the .tpr file
88 CommandLine caller;
89 runner_.useTopGroAndNdxFromDatabase(simulationName);
90 runner_.useStringAsMdpFile(prepareMdpFileContents(
91 prepareMdpFieldValues(simulationName.c_str(), integrator.c_str(), "no", "no")));
92 EXPECT_EQ(0, runner_.callGrompp(caller));
94 // Do mdrun
96 CommandLine mdrunCaller;
97 ASSERT_EQ(0, runner_.callMdrun(mdrunCaller));
99 // Check if expected files are present
101 for (const auto& file : { runner_.fullPrecisionTrajectoryFileName_, runner_.logFileName_,
102 runner_.edrFileName_, fileManager_.getTemporaryFilePath("state.gro"),
103 fileManager_.getTemporaryFilePath("state.cpt") })
105 EXPECT_TRUE(File::exists(file, File::returnFalseOnError))
106 << "File " << file << " was not found.";
111 INSTANTIATE_TEST_CASE_P(Argon12,
112 OutputFiles,
113 ::testing::Combine(::testing::Values("argon12"),
114 ::testing::Values("md", "md-vv")));
116 } // namespace
117 } // namespace test
118 } // namespace gmx