Gromacs  2027.0-dev-20261112-5a4f586
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Protected Member Functions
gmx::test::HardwareTestFixture< TestHelper > Class Template Reference

#include <testutils/include/testutils/hardware_test_fixture.h>

Inherits TestWithParam< TestHelper::DynamicParameters >.

Description

template<typename TestHelper>
class gmx::test::HardwareTestFixture< TestHelper >

Base class for hardware-parameterized tests.

Provides infrastructure for tests using HardwareAndExecutionTestHelper:

See file-level documentation for complete usage examples.

Template Parameters
TestHelperA HardwareAndExecutionTestHelper instantiation that provides the parameterization over input configs and execution modes.
Warning
Do NOT call virtual functions from constructors! Use SetUp() for skip logic.
See Also
HardwareAndExecutionTestHelper, TestHardwareContext

Public Types

using ParametersTuple = typename TestHelper::DynamicParameters
 Parameter tuple type, including input config, execution mode, and hardware contexts.
 

Protected Member Functions

 HardwareTestFixture (typename TestHelper::InputConfigFormatters inputFormatters)
 Constructor. More...
 
void SetUp () override
 SetUp override - performs custom skip checks and creates checker. More...
 
virtual void addCustomSkipReasons (MessageStringCollector &skipReasons)
 Virtual hook for derived classes to add custom skip conditions. More...
 
const TestHardwareContext * hardwareContext () const
 Get hardware context (extracted from parameter tuple)
 
TestReferenceChecker & checker ()
 Get reference checker. More...
 
void activateHardware () const
 Activate hardware (sets device for GPU, no-op for CPU)
 
bool isGpuTest () const
 Check if this is a GPU test.
 
std::optional< int > gpuId () const
 Get GPU ID if GPU test, std::nullopt otherwise.
 
const DeviceContext * deviceContext () const
 Get device context (nullptr for CPU, convenience wrapper for hardwareContext()->deviceContext())
 
const DeviceStream * deviceStream () const
 Get device stream (nullptr for CPU, convenience wrapper for hardwareContext()->deviceStream())
 

Constructor & Destructor Documentation

template<typename TestHelper>
gmx::test::HardwareTestFixture< TestHelper >::HardwareTestFixture ( typename TestHelper::InputConfigFormatters  inputFormatters)
inlineexplicitprotected

Constructor.

Takes input config formatters and automatically creates the RefDataFilenameMaker internally. See file-level documentation for complete usage examples.

Parameters
[in]inputFormattersTuple of formatter functions for input config parameters
Note
High-level hardware capability filtering should be done at test instantiation via testing::Combine with getHardwareContextsWithCapability(). Custom parameter-dependent skip logic can be added via the virtual addCustomSkipReasons() hook, which runs in SetUp(). The reference data checker is created in SetUp() after all skip checks complete.

Member Function Documentation

template<typename TestHelper>
virtual void gmx::test::HardwareTestFixture< TestHelper >::addCustomSkipReasons ( MessageStringCollector &  skipReasons)
inlineprotectedvirtual

Virtual hook for derived classes to add custom skip conditions.

Called from SetUp() (NOT constructor) to add test-specific skip logic. Derived classes can override this to add parameter-dependent skip conditions.

Parameters
[in,out]skipReasonsCollector to append skip reasons to

Default implementation does nothing (no custom skip logic).

Reimplemented in gmx::test::anonymous_namespace{bonded.cpp}::ListedForcesTest.

template<typename TestHelper>
TestReferenceChecker& gmx::test::HardwareTestFixture< TestHelper >::checker ( )
inlineprotected

Get reference checker.

Safe to call after SetUp() completes. Asserts if called before checker is initialized (which should be impossible if used correctly).

template<typename TestHelper>
void gmx::test::HardwareTestFixture< TestHelper >::SetUp ( )
inlineoverrideprotected

SetUp override - performs custom skip checks and creates checker.

Called by GoogleTest after construction is complete. This is where custom skip logic runs via the virtual addCustomSkipReasons() hook.

If derived classes override SetUp(), they MUST call base SetUp() first:

* void SetUp() override {
* // Your setup here...
* }
*

The documentation for this class was generated from the following file: