Gromacs  2016.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Enumerations | Functions | Variables
gmx::test Namespace Reference

Description

Testing utilities namespace.

This namespace contains utilities for writing unit tests, mostly from the Testing Utilities (testutils) module.

Classes

class  AnalysisDataTestInputPointSet
 Represents a single set of points in AnalysisDataTestInputFrame structure. More...
 
class  AnalysisDataTestInputFrame
 Represents a single frame in AnalysisDataTestInput structure. More...
 
class  AnalysisDataTestInput
 Represents static input data for AbstractAnalysisData tests. More...
 
class  AnalysisDataTestFixture
 Test fixture for AbstractAnalysisData testing. More...
 
class  MdrunComparisonFixture
 Declares abstract base text fixture class for integration tests of mdrun functionality that will compare multiple calls to mdrun. More...
 
class  CommandLine
 Helper class for tests that need to construct command lines. More...
 
class  CommandLineTestHelper
 Helper class for tests that construct command lines that need to reference existing files. More...
 
class  CommandLineTestBase
 Test fixture for tests that call a single command-line program with input/output files. More...
 
class  ConfMatch
 Match the contents as an gro file. More...
 
class  IntegrationTestFixture
 Test fixture for integration tests. More...
 
class  InteractiveTestHelper
 Helper class for testing interactive sessions. More...
 
class  TestReferenceChecker
 Handles comparison to test reference data. More...
 
class  TestReferenceData
 Handles creation of and comparison to test reference data. More...
 
class  StringTestBase
 Test fixture for tests that check string formatting. More...
 
class  FloatingPointDifference
 Computes and represents a floating-point difference value. More...
 
class  FloatingPointTolerance
 Specifies a floating-point comparison tolerance and checks whether a difference is within the tolerance. More...
 
class  TestException
 Exception class for reporting errors in tests. More...
 
class  TestFileManager
 Helper for tests that need input and output files. More...
 
class  TestFileInputRedirector
 In-memory implementation for IFileInputRedirector for tests. More...
 
class  TestFileOutputRedirector
 In-memory implementation of IFileOutputRedirector for tests. More...
 
class  TestOptionsProvider
 Provides additional options for the test executable. More...
 
class  ITextBlockMatcher
 Represents a text matcher, matching text stream contents against reference data. More...
 
class  ITextBlockMatcherSettings
 Represents a factory for creating a text matcher. More...
 
class  ExactTextMatch
 Use an exact text match (the contents should be exactly equal). More...
 
class  NoTextMatch
 Do not match the text (the contents are ignored). More...
 
class  XvgMatch
 Match the contents as an xvg file. More...
 

Typedefs

typedef std::shared_ptr
< MockAnalysisDataModule > 
MockAnalysisDataModulePointer
 Smart pointer to manage an MockAnalysisDataModule object.
 
typedef std::tuple< int, bool,
bool, bool > 
SettleTestParameters
 Convenience typedef.
 
typedef std::unique_ptr
< EnergyFrameReader > 
EnergyFrameReaderPtr
 Convenience smart pointer typedef.
 
typedef scoped_cptr< ener_file,
done_ener_file > 
ener_file_ptr
 Convenience smart pointer typedef.
 
typedef scoped_cptr
< t_enxframe, done_enxframe
enxframe_ptr
 Convenience smart pointer typedef.
 
typedef gmx::test::ImdTestFixture ImdTest
 Test fixture for mdrun with IMD settings.
 
typedef MultiSimTest MultiSimTerminationTest
 Convenience typedef.
 
typedef std::unique_ptr
< CommandLine
CommandLinePointer
 Convenience typedef.
 
typedef MultiSimTest ReplicaExchangeEnsembleTest
 Convenience typedef.
 
typedef MultiSimTest ReplicaExchangeTerminationTest
 Convenience typedef.
 
typedef gmx::test::SwapTestFixture CompelTest
 Test fixture for mdrun with "Computational Electrophysiology" settings,.
 
typedef MdrunTestFixture MdrunTerminationTest
 Convenience typedef.
 
typedef scoped_cptr
< gmx_output_env_t,
output_env_done > 
oenv_ptr
 Convenience smart pointer typedef.
 
typedef scoped_cptr
< t_trxstatus, close_trx > 
trxstatus_file_ptr
 Convenience smart pointer typedef.
 
typedef scoped_cptr
< t_trxframe, done_trxframe
trxframe_ptr
 Convenience smart pointer typedef.
 
typedef std::unique_ptr
< TrajectoryFrameReader > 
TrajectoryFrameReaderPtr
 Convenience smart pointer typedef.
 
typedef std::unique_ptr
< ITextBlockMatcher
TextBlockMatcherPointer
 Smart pointer for managing a ITextBlockMatcher.
 

Enumerations

enum  ReferenceDataMode { erefdataCompare, erefdataCreateMissing, erefdataUpdateChanged, erefdataUpdateAll }
 Mode of operation for reference data handling. More...
 

Functions

EnergyFrameReaderPtr openEnergyFileToReadFields (const std::string &filename, const std::vector< std::string > &requiredEnergyFieldNames)
 Open the file and return an object that can read the required fields from frames of an .edr file. More...
 
t_enxframe * make_enxframe ()
 Helper function to obtain resources.
 
void done_enxframe (t_enxframe *fr)
 Helper function to clean up resources. More...
 
void compareFrames (const std::pair< EnergyFrame, EnergyFrame > &frames, FloatingPointTolerance tolerance)
 Compare all fields of reference with all matching fields from test. More...
 
void organizeMdpFile (SimulationRunner *runner)
 Build a simple .mdp file.
 
t_trxframe * make_trxframe ()
 Helper function to obtain resources.
 
void done_trxframe (t_trxframe *fr)
 Helper function to clean up resources. More...
 
void compareFrames (const std::pair< TrajectoryFrame, TrajectoryFrame > &frames, FloatingPointTolerance tolerance)
 Compare the fields of the two frames for equality within the tolerance. More...
 
void checkConfFile (TextInputStream *input, TestReferenceChecker *checker, const ConfMatchSettings &settings)
 Adds content of a gro file to TestReferenceChecker object. More...
 
double convertDouble (const std::string &value)
 Helper function to parse a floating-point value.
 
double convertDoubleReferenceValue (const std::string &value)
 Helper function to parse a floating-point reference data value.
 
void initReferenceData (IOptionsContainer *options)
 Initializes reference data handling. More...
 
static void throwIfNonEmptyAndOnlyWhitespace (const std::string &s, const char *id)
 Throw a TestException if the caller tries to write particular refdata that can't work. More...
 
void registerTestOptions (const char *name, TestOptionsProvider *provider)
 Registers a test option provider with the test framework. More...
 
void initTestOptions (IOptionsContainer *options)
 Initializes the options from all registered test providers. More...
 
void checkXvgFile (TextInputStream *input, TestReferenceChecker *checker, const XvgMatchSettings &settings)
 Adds content of xvg file to TestReferenceChecker object. More...
 

Variables

const double g_positions []
 Database of 51 water atom input positions (DIM reals per atom, taken from spc216.gro) for use as test inputs.
 
matrix g_box = {{real(1.86206), 0, 0}, {0, real(1.86206), 0}, {0, 0, real(1.86206)}}
 Simple cubic simulation box to use in tests.
 
const char * g_butaneTopFileFormatString
 Format string for building a configurable .top file.
 
static bool g_bDeleteFilesAfterTest = true
 Controls whether TestFileManager should delete temporary files after the test finishes. More...
 

Function Documentation

void gmx::test::checkConfFile ( TextInputStream *  input,
TestReferenceChecker *  checker,
const ConfMatchSettings &  settings 
)

Adds content of a gro file to TestReferenceChecker object.

Parameters
[in]inputStream that provides the gro content.
[in,out]checkerChecker to use.
[in]settingsSettings to use for matching.

Parses a gro file from the input stream, and checks the contents against reference data (only first two lines for now).

See Also
ConfMatch
void gmx::test::checkXvgFile ( TextInputStream *  input,
TestReferenceChecker *  checker,
const XvgMatchSettings &  settings 
)

Adds content of xvg file to TestReferenceChecker object.

Parameters
[in]inputStream that provides the xvg content.
[in,out]checkerChecker to use.
[in]settingsSettings to use for matching.

Parses an xvg file from the input stream, and checks the contents against reference data. settings can be used to customize the matching. Only a single data set is supported (but multiple columns work). A subset of xmgrace formatting is also checked; static content that is nearly always the same is skipped.

See Also
XvgMatch
void gmx::test::compareFrames ( const std::pair< TrajectoryFrame, TrajectoryFrame > &  frames,
FloatingPointTolerance  tolerance 
)

Compare the fields of the two frames for equality within the tolerance.

The two frames are required to have valid and matching values for time and step. Positions, velocities and/or forces will be compared when present in both frames, and expected to be equal within tolerance.

void gmx::test::compareFrames ( const std::pair< EnergyFrame, EnergyFrame > &  frames,
FloatingPointTolerance  tolerance 
)

Compare all fields of reference with all matching fields from test.

Ignore any key found in either reference or test that is not found in the other. For all keys found in both frames, compare the values with EXPECT_REAL_EQ_TOL and the given tolerance.

void gmx::test::done_enxframe ( t_enxframe *  fr)

Helper function to clean up resources.

Helper function to free resources (NB free_enxframe only frees the contents, not the pointer itself)

void gmx::test::done_trxframe ( t_trxframe *  fr)

Helper function to clean up resources.

Helper function to free all resources.

EnergyFrameReaderPtr gmx::test::openEnergyFileToReadFields ( const std::string &  filename,
const std::vector< std::string > &  requiredEnergyFieldNames 
)

Open the file and return an object that can read the required fields from frames of an .edr file.

Parameters
[in]filenameName of the energy file to use
[in]requiredEnergyFieldNamesNames of the energy fields that the caller requires to be present for an .edr file frame to be considered valid
Exceptions
FileIOErrorIf the .edr file cannot be opened
APIErrorIf any required energy field is not present in the file
std::bad_allocWhen out of memory

This function is intended to have the main responsibility for making EnergyFrameReader objects.

static void gmx::test::throwIfNonEmptyAndOnlyWhitespace ( const std::string &  s,
const char *  id 
)
static

Throw a TestException if the caller tries to write particular refdata that can't work.

If the string to write is non-empty and has only whitespace, TinyXML2 can't read it correctly, so throw an exception for this case, so that we can't accidentally use it and run into mysterious problems.

Todo:
Eliminate this limitation of TinyXML2. See e.g. https://github.com/leethomason/tinyxml2/issues/432

Variable Documentation

bool gmx::test::g_bDeleteFilesAfterTest = true
static

Controls whether TestFileManager should delete temporary files after the test finishes.