Gromacs
2016.6
|
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 | MockModule |
Mock implementation of gmx::ICommandLineModule. More... | |
class | MockOptionsModule |
Mock implementation of gmx::ICommandLineOptionsModule. More... | |
class | CommandLineModuleManagerTestBase |
Test fixture for tests using gmx::CommandLineModuleManager. More... | |
class | SettleTest |
Test fixture for testing SETTLE position updates. More... | |
class | SignalTest |
Test fixture for mdrun signalling. More... | |
class | SimdBaseTest |
Base class for SIMD test fixtures. More... | |
class | SimdTest |
Test fixture for SIMD tests. More... | |
class | Simd4Test |
Test fixture for SIMD4 tests - contains test settings. More... | |
class | AbstractTrajectoryAnalysisModuleTestFixture |
Test fixture for trajectory analysis modules. More... | |
class | TrajectoryAnalysisModuleTestFixture |
Test fixture for a trajectory analysis module. More... | |
class | EnergyFrameReader |
Manages returning an EnergyFrame containing required energy field values read from successive frames of an .edr file. More... | |
class | EnergyFrame |
Contains the content of an .edr frame read by an EnergyFrameReader. More... | |
class | MdrunComparisonFixture |
Declares abstract base text fixture class for integration tests of mdrun functionality that will compare multiple calls to mdrun. More... | |
class | SimulationRunner |
Helper object for running grompp and mdrun in integration tests of mdrun functionality. More... | |
class | MdrunTestFixtureBase |
Declares test fixture base class for integration tests of mdrun functionality. More... | |
class | MdrunTestFixture |
Declares test fixture class for integration tests of mdrun functionality that use a single call of mdrun. More... | |
class | ParameterizedMdrunTestFixture |
Parameterized test fixture for mdrun integration tests. More... | |
class | MultiSimTest |
Test fixture for multi-sim functionality. More... | |
class | BondedInteractionsTest |
Test fixture for bonded interactions. More... | |
class | TerminationHelper |
Help test mdrun termination behaviour. More... | |
class | TrajectoryFrameReader |
Manages returning a t_trxframe whose contents were read from successive frames of an trajectory file. More... | |
class | TrajectoryFrame |
Contains the content of a trajectory frame read by an TrajectoryFrameReader. 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 | |
::std::vector< real > | simdReal2Vector (const SimdReal simd) |
Convert SIMD real to std::vector<real>. More... | |
SimdReal | vector2SimdReal (const std::vector< real > &v) |
Return floating-point SIMD value from std::vector<real>. More... | |
SimdReal | setSimdRealFrom3R (real r0, real r1, real r2) |
Set SIMD register contents from three real values. More... | |
SimdReal | setSimdRealFrom1R (real value) |
Set SIMD register contents from single real value. More... | |
std::vector< int > | simdInt2Vector (const SimdInt32 simd) |
Convert SIMD integer to std::vector<int>. More... | |
SimdInt32 | vector2SimdInt (const std::vector< int > &v) |
Return 32-bit integer SIMD value from std::vector<int>. More... | |
SimdInt32 | setSimdIntFrom3I (int i0, int i1, int i2) |
Set SIMD register contents from three int values. More... | |
SimdInt32 | setSimdIntFrom1I (int value) |
Set SIMD register contents from single integer value. More... | |
::std::vector< real > | simd4Real2Vector (const Simd4Real simd4) |
Convert SIMD4 real to std::vector<real>. More... | |
Simd4Real | vector2Simd4Real (const std::vector< real > &v) |
Return floating-point SIMD4 value from std::vector<real>. More... | |
Simd4Real | setSimd4RealFrom3R (real r0, real r1, real r2) |
Set SIMD4 register contents from three real values. More... | |
Simd4Real | setSimd4RealFrom1R (real value) |
Set SIMD4 register contents from single real value. More... | |
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... | |
void | initMPIOutput () |
Customizes test output and test failure handling for MPI runs. 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. | |
ReferenceDataEntry::EntryPointer | readReferenceDataFile (const std::string &path) |
Loads reference data from an XML file. More... | |
void | writeReferenceDataFile (const std::string &path, const ReferenceDataEntry &root) |
Saves reference data to an XML file. More... | |
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... | |
static inline::testing::AssertionResult | plainAssertHelper (const char *, const ::testing::AssertionResult &expr) |
Helper method for (EXPECT|ASSERT)_PLAIN . More... | |
void | initTestUtils (const char *dataPath, const char *tempPath, bool usesMpi, int *argc, char ***argv) |
Initializes the test utilities library. More... | |
void | finalizeTestUtils () |
Finalizes the test utilities library. 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... | |
Assertions for floating-point comparison | |
These routines extend See gmx::test::FloatingPointTolerance for the possible ways to specify the tolerance, and gmx::test::FloatingPointDifference for some additional details of the difference calculation. | |
template<typename FloatType > | |
static inline::testing::AssertionResult | assertEqualWithinTolerance (const char *expr1, const char *expr2, const char *, FloatType value1, FloatType value2, const FloatingPointTolerance &tolerance) |
Assertion predicate formatter for comparing two floating-point values. 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 SimdReal | rSimd_1_2_3 = setSimdRealFrom3R(1, 2, 3) |
Generic (different) fp values. | |
const SimdReal | rSimd_4_5_6 = setSimdRealFrom3R(4, 5, 6) |
Generic (different) fp values. | |
const SimdReal | rSimd_7_8_9 = setSimdRealFrom3R(7, 8, 9) |
Generic (different) fp values. | |
const SimdReal | rSimd_5_7_9 = setSimdRealFrom3R(5, 7, 9) |
rSimd_1_2_3 + rSimd_4_5_6. | |
const SimdReal | rSimd_m1_m2_m3 = setSimdRealFrom3R(-1, -2, -3) |
Generic negative floating-point values. | |
const SimdReal | rSimd_3_1_4 = setSimdRealFrom3R(3, 1, 4) |
Used to test min/max. | |
const SimdReal | rSimd_m3_m1_m4 = setSimdRealFrom3R(-3, -1, -4) |
negative rSimd_3_1_4. | |
const SimdReal | rSimd_2p25 = setSimdRealFrom1R(2.25) |
Value that rounds down. | |
const SimdReal | rSimd_3p25 = setSimdRealFrom1R(3.25) |
Value that rounds down. | |
const SimdReal | rSimd_3p75 = setSimdRealFrom1R(3.75) |
Value that rounds up. | |
const SimdReal | rSimd_m2p25 = setSimdRealFrom1R(-2.25) |
Negative value that rounds up. | |
const SimdReal | rSimd_m3p25 = setSimdRealFrom1R(-3.25) |
Negative value that rounds up. | |
const SimdReal | rSimd_m3p75 = setSimdRealFrom1R(-3.75) |
Negative value that rounds down. More... | |
const SimdReal | rSimd_Exp |
Three large floating-point values whose exponents are >32. More... | |
const SimdInt32 | iSimd_1_2_3 = setSimdIntFrom3I(1, 2, 3) |
Three generic ints. | |
const SimdInt32 | iSimd_4_5_6 = setSimdIntFrom3I(4, 5, 6) |
Three generic ints. | |
const SimdInt32 | iSimd_7_8_9 = setSimdIntFrom3I(7, 8, 9) |
Three generic ints. | |
const SimdInt32 | iSimd_5_7_9 = setSimdIntFrom3I(5, 7, 9) |
iSimd_1_2_3 + iSimd_4_5_6. | |
const SimdInt32 | iSimd_1M_2M_3M = setSimdIntFrom3I(1000000, 2000000, 3000000) |
Term1 for 32bit add/sub. | |
const SimdInt32 | iSimd_4M_5M_6M = setSimdIntFrom3I(4000000, 5000000, 6000000) |
Term2 for 32bit add/sub. | |
const SimdInt32 | iSimd_5M_7M_9M = setSimdIntFrom3I(5000000, 7000000, 9000000) |
iSimd_1M_2M_3M + iSimd_4M_5M_6M. | |
const SimdInt32 | iSimd_0xF0F0F0F0 = setSimdIntFrom1I(0xF0F0F0F0) |
Bitpattern to test integer logical operations. | |
const SimdInt32 | iSimd_0xCCCCCCCC = setSimdIntFrom1I(0xCCCCCCCC) |
Bitpattern to test integer logical operations. | |
const SimdReal | rSimd_Bits1 |
Pattern F0 repeated to fill single/double. | |
const SimdReal | rSimd_Bits2 |
Pattern CC repeated to fill single/double. | |
const SimdReal | rSimd_Bits3 |
Pattern C0 repeated to fill single/double. | |
const SimdReal | rSimd_Bits4 |
Pattern 0C repeated to fill single/double. | |
const SimdReal | rSimd_Bits5 |
Pattern FC repeated to fill single/double. | |
const SimdReal | rSimd_Bits6 |
Pattern 3C repeated to fill single/double. | |
const Simd4Real | rSimd4_1_2_3 = setSimd4RealFrom3R(1, 2, 3) |
Generic (different) fp values. | |
const Simd4Real | rSimd4_4_5_6 = setSimd4RealFrom3R(4, 5, 6) |
Generic (different) fp values. | |
const Simd4Real | rSimd4_7_8_9 = setSimd4RealFrom3R(7, 8, 9) |
Generic (different) fp values. | |
const Simd4Real | rSimd4_5_7_9 = setSimd4RealFrom3R(5, 7, 9) |
rSimd_1_2_3 + rSimd_4_5_6. | |
const Simd4Real | rSimd4_m1_m2_m3 = setSimd4RealFrom3R(-1, -2, -3) |
Generic negative fp values. | |
const Simd4Real | rSimd4_3_1_4 = setSimd4RealFrom3R(3, 1, 4) |
Used to test min/max. | |
const Simd4Real | rSimd4_m3_m1_m4 = setSimd4RealFrom3R(-3, -1, -4) |
negative rSimd_3_1_4. | |
const Simd4Real | rSimd4_2p25 = setSimd4RealFrom1R(2.25) |
Value that rounds down. | |
const Simd4Real | rSimd4_3p75 = setSimd4RealFrom1R(3.75) |
Value that rounds up. | |
const Simd4Real | rSimd4_m2p25 = setSimd4RealFrom1R(-2.25) |
Negative value that rounds up. | |
const Simd4Real | rSimd4_m3p75 = setSimd4RealFrom1R(-3.75) |
Negative value that rounds down. More... | |
const Simd4Real | rSimd4_Exp |
Three large floating-point values whose exponents are >32. More... | |
const Simd4Real | rSimd4_Bits1 |
Pattern F0 repeated to fill single/double. | |
const Simd4Real | rSimd4_Bits2 |
Pattern CC repeated to fill single/double. | |
const Simd4Real | rSimd4_Bits3 |
Pattern C0 repeated to fill single/double. | |
const Simd4Real | rSimd4_Bits4 |
Pattern 0C repeated to fill single/double. | |
const Simd4Real | rSimd4_Bits5 |
Pattern FC repeated to fill single/double. | |
const Simd4Real | rSimd4_Bits6 |
Pattern 3C repeated to fill single/double. | |
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... | |
void gmx::test::checkConfFile | ( | TextInputStream * | input, |
TestReferenceChecker * | checker, | ||
const ConfMatchSettings & | settings | ||
) |
Adds content of a gro file to TestReferenceChecker object.
[in] | input | Stream that provides the gro content. |
[in,out] | checker | Checker to use. |
[in] | settings | Settings 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).
void gmx::test::checkXvgFile | ( | TextInputStream * | input, |
TestReferenceChecker * | checker, | ||
const XvgMatchSettings & | settings | ||
) |
Adds content of xvg file to TestReferenceChecker object.
[in] | input | Stream that provides the xvg content. |
[in,out] | checker | Checker to use. |
[in] | settings | Settings 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.
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.
[in] | filename | Name of the energy file to use |
[in] | requiredEnergyFieldNames | Names of the energy fields that the caller requires to be present for an .edr file frame to be considered valid |
FileIOError | If the .edr file cannot be opened |
APIError | If any required energy field is not present in the file |
std::bad_alloc | When out of memory |
This function is intended to have the main responsibility for making EnergyFrameReader objects.
|
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.
|
static |
Controls whether TestFileManager should delete temporary files after the test finishes.