/** Source directory for the build */
#define CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@"
+/** Directory for test input files */
+#define GMX_TESTSIMULATIONDATABASE_DIR "@CMAKE_SOURCE_DIR@/src/testutils/simulationdatabase"
+
/** Binary directory for the build */
#define CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@"
CommandLine caller;
caller.append("grompp");
caller.addOption("-f", mdpInputFileName);
- caller.addOption("-p", TestFileManager::getInputFilePath(filename));
+ caller.addOption("-p", TestFileManager::getInputFilePath(filename + ".top"));
caller.addOption("-c", TestFileManager::getInputFilePath(filename + ".pdb"));
caller.addOption("-o", tprName);
EXPECT_EQ(0, gmx_grompp(caller.argc(), caller.argv()));
//! Global test input data path set with setDataInputDirectory().
static std::string s_inputDirectory;
+ //! Global path to simulation input database set with setTestSimulationDataBaseDirectory().
+ static std::string s_simulationDatabaseDirectory;
+
//! Global temporary output directory for tests, set with setGlobalOutputTempDirectory().
static const char *s_globalOutputTempDirectory;
};
std::string TestFileManager::Impl::s_inputDirectory;
+std::string TestFileManager::Impl::s_simulationDatabaseDirectory;
const char *TestFileManager::Impl::s_globalOutputTempDirectory = nullptr;
/** Controls whether TestFileManager should delete temporary files
after the test finishes. */
std::string TestFileManager::getInputFilePath(const char *filename)
{
- return Path::join(getInputDataDirectory(), filename);
+ // Check if file is present in local directory.
+ if (File::exists(Path::join(getInputDataDirectory(), filename), File::returnFalseOnError))
+ {
+ return Path::join(getInputDataDirectory(), filename);
+ }
+ else if (File::exists(Path::join(getTestSimulationDatabaseDirectory(), filename), File::returnFalseOnError))
+ {
+ // Assume file is in global directory for simulation input files.
+ return Path::join(getTestSimulationDatabaseDirectory(), filename);
+ }
+ else
+ {
+ // Assume file is present locally without full name (e.g. extension).
+ return Path::join(getInputDataDirectory(), filename);
+ }
}
std::string TestFileManager::getInputFilePath(const std::string &filename)
return impl_->outputTempDirectory_.c_str();
}
+const char *TestFileManager::getTestSimulationDatabaseDirectory()
+{
+ GMX_RELEASE_ASSERT(!Impl::s_simulationDatabaseDirectory.empty(), "Path for simulation input database directory is not set");
+ return Impl::s_simulationDatabaseDirectory.c_str();
+}
+
void TestFileManager::setInputDataDirectory(const std::string &path)
{
// There is no need to protect this by a mutex, as this is called in early
Impl::s_inputDirectory = path;
}
+void TestFileManager::setTestSimulationDatabaseDirectory(const std::string &path)
+{
+ // There is no need to protect this by a mutex, as this is called in early
+ // initialization of the tests.
+ GMX_RELEASE_ASSERT(Directory::exists(path),
+ "Simulation database directory does not exist");
+ Impl::s_simulationDatabaseDirectory = path;
+}
+
void TestFileManager::setGlobalOutputTempDirectory(const char *path)
{
// There is no need to protect this by a mutex, as this is called in early
* This is used to provide input files for the tests, and also to
* store test reference data persistently (see TestReferenceData).
*
- * Note that setInputDataDirectory() and
+ * Note that setInputDataDirectory(), setTestSimulationDataBaseDirectory() and
* setGlobalOutputTempDirectory() must be called in setup code, before
* creating any objects of this class that are used for accessing the
* paths for these respective directories. Code in tests should avoid
//! \copydoc TestFileManager::getInputFilePath(const char *)
static std::string getInputFilePath(const std::string &filename);
+ /*! \brief
+ * Returns the path to the simulation input database directory.
+ *
+ * \returns Path to simulation input database directory.
+ */
+ static const char *getTestSimulationDatabaseDirectory();
+
/*! \brief
* Returns the path to the test input directory.
*
*/
static void setInputDataDirectory(const std::string &path);
+ /*! \brief
+ * Sets the input directory for simulation input files.
+ *
+ * \param[in] path Path to look up the directory for simulation input files.
+ *
+ * \p path must name an exisitng directory.
+ *
+ * This function is automatically called by unittest_main.cpp through
+ * initTestUtils().
+ */
+ static void setTestSimulationDatabaseDirectory(const std::string &path);
+
/*! \brief Returns the path to the global test output
* temporary directory for future TestFileManager objects.
*
{
TestFileManager::setGlobalOutputTempDirectory(tempPath);
}
+ TestFileManager::setTestSimulationDatabaseDirectory(
+ GMX_TESTSIMULATIONDATABASE_DIR);
+
bool bHelp = false;
std::string sourceRoot;
Options options;
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
*
* This function is automatically called by unittest_main.cpp.
*
+ * \param[in] dataPath Filepath to input files.
+ * \param[in] tempPath Filepath to temporary files.
+ * \param[in] usesMpi If the test is run with MPI or not.
+ * \param[in] usesHardwareDetection If hardwaredetection is enabled.
+ * \param[in] argc Number of cmdline options
+ * \param[in] argv Cmdline options.
+ *
* \ingroup module_testutils
*/
void initTestUtils(const char *dataPath, const char *tempPath, bool usesMpi,