Refactor mdrun integration tests
[alexxy/gromacs.git] / src / programs / mdrun / tests / rerun.cpp
index 68573f0a7dd1e2efa700dfbc76744209fc8dd6d2..a73f2623be7afd3f8f6325378aef60254897b97a 100644 (file)
  * \author Mark Abraham <mark.j.abraham@gmail.com>
  * \ingroup module_mdrun
  */
+#include "gmxpre.h"
+
+#include "config.h"
+
 #include <gtest/gtest.h>
-#include "moduletest.h"
+
 #include "gromacs/options/filenameoption.h"
+
 #include "testutils/cmdlinetest.h"
 
+#include "moduletest.h"
+
 namespace
 {
 
 //! Test fixture for mdrun -rerun
-typedef gmx::test::MdrunTestFixture RerunTest;
+class MdrunRerun : public gmx::test::MdrunTestFixture,
+                   public ::testing::WithParamInterface<const char *>
+{
+};
 
 /* Among other things, this test ensures mdrun can read a trajectory. */
-TEST_F(RerunTest, RerunExitsNormally)
+TEST_P(MdrunRerun, WithDifferentInputFormats)
 {
-    useEmptyMdpFile();
-    useTopGroAndNdxFromDatabase("spc2");
-    EXPECT_EQ(0, callGrompp());
+    runner_.useEmptyMdpFile();
+    runner_.useTopGroAndNdxFromDatabase("spc2");
+    EXPECT_EQ(0, runner_.callGrompp());
 
-    std::string rerunFileName = fileManager_.getInputFilePath("spc2.trr");
+    std::string rerunFileName = fileManager_.getInputFilePath(GetParam());
 
     ::gmx::test::CommandLine rerunCaller;
     rerunCaller.append("mdrun");
     rerunCaller.addOption("-rerun", rerunFileName);
-    ASSERT_EQ(0, callMdrun(rerunCaller));
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
 }
 
+/*! \brief Helper array of input files present in the source repo
+ * database. These all have two identical frames of two SPC water
+ * molecules, which were generated via trjconv from the .gro
+ * version. */
+const char *trajectoryFileNames[] = {
+    "../../../gromacs/gmxana/legacytests/spc2-traj.trr",
+#if defined GMX_USE_TNG && defined HAVE_ZLIB
+    "../../../gromacs/gmxana/legacytests/spc2-traj.tng",
+#endif
+    "../../../gromacs/gmxana/legacytests/spc2-traj.xtc",
+    "../../../gromacs/gmxana/legacytests/spc2-traj.gro",
+    "../../../gromacs/gmxana/legacytests/spc2-traj.pdb",
+    "../../../gromacs/gmxana/legacytests/spc2-traj.g96"
+};
+// TODO later. Find a better way to manage this file database and
+// these string arrays that index it
+
+#ifdef __INTEL_COMPILER
+#pragma warning( disable : 177 )
+#endif
+
+INSTANTIATE_TEST_CASE_P(NoFatalErrorFrom,
+                        MdrunRerun,
+                            ::testing::ValuesIn(gmx::ArrayRef<const char*>(trajectoryFileNames)));
+
 /*! \todo Add other tests for mdrun -rerun, e.g.
  *
  * - RerunReproducesRunWhenRunOnlyWroteEnergiesOnNeighborSearchSteps