Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
TestFrame Class Reference

#include "/Werk/devel/lumi/tests/core/steam/engine/testframe.hpp"

Description

Mock data frame for simulated rendering.

A test frame can be created and placed instead of a real data frame. It doesn't depend on any external libraries and will be self-maintaining. Placeholder functions are provided for assignment (simulating the actual calculations); additional diagnostic functions allow to verify the performed operations after-the fact

Each TestFrame is automatically filled with pseudo random data; multiple frames are arranged in sequences and channels, causing the random data to be reproducible yet different within each frame. TestFrame's lifecycle is tracked and marked in an embedded state field. Moreover, the contents of the data block can be verified, because the sequence of bytes is reproducible, based on the channel and sequence number of the test frame.

See also
TestFrame_test
OutputSlotProtocol_test

Definition at line 68 of file testframe.hpp.

Classes

struct  Meta
 

Static Public Member Functions

static void reseed ()
 discard all cached testData and recalibrate data generation
 
static bool isAlive (void *memLocation)
 Helper to verify that a given memory location holds an active TestFrame instance (created, not yet destroyed)
 
static bool isDead (void *memLocation)
 Helper to verify a given memory location holds an already destroyed TestFrame instance.
 

Public Member Functions

 ~TestFrame ()
 
 TestFrame (uint seq=0, uint family=0)
 
 TestFrame (TestFrame const &)
 
TestFrameoperator= (TestFrame const &)
 
HashVal markChecksum ()
 recompute and store checksum based on current contents
 
HashVal getChecksum ()
 access current checksum without recomputing.
 
bool isAlive () const
 
bool isDead () const
 
bool isSane () const
 
bool isValid () const
 
bool isPristine () const
 
bool operator== (void *memLocation) const
 
_Arrdata ()
 Array-style direct access to the payload data.
 
_Arr const & data () const
 
_A64data64 ()
 
_A64 const & data64 () const
 

Friends

bool operator== (TestFrame const &f1, TestFrame const &f2)
 
bool operator!= (TestFrame const &f1, TestFrame const &f2)
 

Private Types

enum  StageOfLife {
  CREATED ,
  EMITTED ,
  DISCARDED
}
 
using _Arr = std::array< char, BUFFSIZ >
 
using _A64 = std::array< uint64_t, BUFFSIZ/sizeof(uint64_t)>
 

Private Member Functions

void buildData ()
 Generate baseline data content based on the Meta::distinction seed.
 
MetaaccessHeader ()
 
Meta const & accessHeader () const
 
bool contentEquals (TestFrame const &o) const
 
bool matchDistinction () const
 verify the current data was not touched since initialisation
 
StageOfLife currStage () const
 
HashVal computeChecksum () const
 
bool hasValidChecksum () const
 

Private Attributes

std::byte buffer_ [sizeof(_Arr)]
 inline storage buffer for the payload media data
 
Meta header_
 Metadata record located behind the data buffer.
 

Static Private Attributes

static constexpr size_t BUFFSIZ = 1024
 

Constructor & Destructor Documentation

◆ ~TestFrame()

~TestFrame ( )

Definition at line 223 of file testframe.cpp.

References TestFrame::DISCARDED, TestFrame::header_, and TestFrame::Meta::stage.

◆ TestFrame() [1/2]

TestFrame ( uint  seq = 0,
uint  family = 0 
)

Definition at line 229 of file testframe.cpp.

References TestFrame::buildData(), TestFrame::CREATED, TestFrame::Meta::distinction, TestFrame::header_, TestFrame::isPristine(), and TestFrame::Meta::stage.

+ Here is the call graph for this function:

◆ TestFrame() [2/2]

TestFrame ( TestFrame const &  o)

Definition at line 238 of file testframe.cpp.

References TestFrame::CREATED, TestFrame::data(), TestFrame::header_, and TestFrame::Meta::stage.

+ Here is the call graph for this function:

Member Typedef Documentation

◆ _Arr

using _Arr = std::array<char,BUFFSIZ>
private

Definition at line 75 of file testframe.hpp.

◆ _A64

using _A64 = std::array<uint64_t, BUFFSIZ/sizeof(uint64_t)>
private

Definition at line 76 of file testframe.hpp.

Member Enumeration Documentation

◆ StageOfLife

enum StageOfLife
private
Enumerator
CREATED 
EMITTED 
DISCARDED 

Definition at line 70 of file testframe.hpp.

Member Function Documentation

◆ reseed()

void reseed ( )
static

discard all cached testData and recalibrate data generation

Remarks
this function should be invoked at the start of any test which requires reproducible data values in the TestFrame. It generates a new base seed to distinguish individual data frames. The seed is drawn from the lib::defaultGen, and thus will be reproducible if the latter has been reseeded beforehand.
Warning
after invoking reseed(), the validity of previously generated frames can no longer be verified.

Definition at line 204 of file testframe.cpp.

References lib::defaultGen.

Referenced by NodeDevel_test::run(), OutputProxyProvider_test::run(), TestFrame_test::run(), and TestFrame_test::useFrameTable().

+ Here is the caller graph for this function:

◆ operator=()

TestFrame & operator= ( TestFrame const &  o)

Definition at line 246 of file testframe.cpp.

References TestFrame::CREATED, TestFrame::data(), TestFrame::header_, TestFrame::isAlive(), util::isSameAdr(), and TestFrame::Meta::stage.

+ Here is the call graph for this function:

◆ markChecksum()

HashVal markChecksum ( )

recompute and store checksum based on current contents

Remarks
can be used to mark a manipulated new content as valid

Definition at line 364 of file testframe.cpp.

References TestFrame::accessHeader(), TestFrame::Meta::checksum, and TestFrame::computeChecksum().

Referenced by TestFrame::buildData(), steam::engine::test::ont::combineFrames(), steam::engine::test::ont::manipulateFrame(), TestFrame_test::simpleUsage(), and TestFrame_test::verifyDataContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChecksum()

HashVal getChecksum ( )

access current checksum without recomputing.

Definition at line 370 of file testframe.cpp.

References TestFrame::accessHeader(), and TestFrame::Meta::checksum.

Referenced by NodeLink_test::trigger_node_port_invocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAlive() [1/2]

bool isAlive ( void *  memLocation)
static

Helper to verify that a given memory location holds an active TestFrame instance (created, not yet destroyed)

Returns
true if the TestFrame datastructure is intact and marked as still alive.
Note
performing an unchecked conversion of the given memory location to be accessed as TestFrame. The sanity of the data found at that location is checked as well, not only the lifecycle flag.

Definition at line 421 of file testframe.cpp.

References TestFrame::isAlive().

Referenced by TestFrame::isAlive(), TestFrame_test::verifyDataContent(), and BufferProviderProtocol_test::verifyObjectAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDead() [1/2]

bool isDead ( void *  memLocation)
static

Helper to verify a given memory location holds an already destroyed TestFrame instance.

Definition at line 428 of file testframe.cpp.

References TestFrame::isDead().

Referenced by TestFrame::isDead(), and BufferProviderProtocol_test::verifyObjectAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAlive() [2/2]

bool isAlive ( ) const

Definition at line 402 of file testframe.cpp.

References TestFrame::isDead(), and TestFrame::isSane().

Referenced by TestFrame::operator=(), TestFrame_test::verifyFrameLifecycle(), and BufferMetadata_test::verifyStandardCase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDead() [2/2]

bool isDead ( ) const

Definition at line 409 of file testframe.cpp.

References TestFrame::currStage(), TestFrame::DISCARDED, and TestFrame::isSane().

Referenced by TestFrame::isAlive(), TestFrame_test::verifyFrameLifecycle(), and BufferMetadata_test::verifyStandardCase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSane()

bool isSane ( ) const

Definition at line 382 of file testframe.cpp.

References TestFrame::header_, and TestFrame::Meta::isPlausible().

Referenced by TestFrame::isAlive(), TestFrame::isDead(), TestFrame::isValid(), TestFrame::operator==(), TrackingHeapBlockProvider_test::simpleExample(), NodeDevel_test::testRand_simpleUsage(), TestFrame_test::verifyDataContent(), and BufferProviderProtocol_test::verifyObjectAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValid()

bool isValid ( ) const

Definition at line 388 of file testframe.cpp.

References TestFrame::hasValidChecksum(), and TestFrame::isSane().

Referenced by TestFrame::isPristine(), OutputProxyProvider_test::run(), TestFrame_test::simpleUsage(), NodeDevel_test::testRand_buildFilterNode(), NodeDevel_test::testRand_buildMixNode(), NodeLink_test::trigger_node_port_invocation(), and TestFrame_test::verifyDataContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPristine()

bool isPristine ( ) const

Definition at line 395 of file testframe.cpp.

References TestFrame::isValid(), and TestFrame::matchDistinction().

Referenced by TestFrame::TestFrame(), OutputProxyProvider_test::run(), NodeDevel_test::testRand_buildFilterNode(), NodeDevel_test::testRand_simpleUsage(), NodeLink_test::trigger_node_port_invocation(), TestFrame_test::useFrameTable(), and TestFrame_test::verifyDataContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==()

bool operator== ( void *  memLocation) const

Definition at line 307 of file testframe.cpp.

References TestFrame::isSane().

+ Here is the call graph for this function:

◆ data() [1/2]

_Arr & data ( )
inline

Array-style direct access to the payload data.

Definition at line 133 of file testframe.hpp.

References TestFrame::buffer_.

Referenced by TestFrame::TestFrame(), steam::engine::test::ont::combineFrames(), TestFrame::computeChecksum(), TestFrame::contentEquals(), TestFrame::operator=(), TestFrame_test::simpleUsage(), TestFrame_test::useFrameTable(), and TestFrame_test::verifyDataContent().

+ Here is the caller graph for this function:

◆ data() [2/2]

_Arr const & data ( ) const
inline

Definition at line 134 of file testframe.hpp.

References TestFrame::buffer_.

◆ data64() [1/2]

_A64 & data64 ( )
inline

Definition at line 135 of file testframe.hpp.

References TestFrame::buffer_.

Referenced by TestFrame::buildData(), steam::engine::test::ont::manipulateFrame(), steam::engine::test::ont::manipulateMultichan(), TestFrame::matchDistinction(), and TestFrame_test::verifyDataContent().

+ Here is the caller graph for this function:

◆ data64() [2/2]

_A64 const & data64 ( ) const
inline

Definition at line 136 of file testframe.hpp.

References TestFrame::buffer_.

◆ buildData()

void buildData ( )
private

Generate baseline data content based on the Meta::distinction seed.

Remarks
the seed is a discriminator based on both the »family« and the frameNo within this family; thus closely related frames are very unlikely to hold the same baseline data. Of course, follow-up manipulations could change the data, which should be documented by markChecksum().

Definition at line 330 of file testframe.cpp.

References TestFrame::accessHeader(), TestFrame::data64(), and TestFrame::markChecksum().

Referenced by TestFrame::TestFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ accessHeader() [1/2]

TestFrame::Meta & accessHeader ( )
private

Definition at line 278 of file testframe.cpp.

References TestFrame::header_, and TestFrame::Meta::isPlausible().

Referenced by TestFrame::buildData(), TestFrame::getChecksum(), TestFrame::hasValidChecksum(), TestFrame::markChecksum(), and TestFrame::matchDistinction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ accessHeader() [2/2]

TestFrame::Meta const & accessHeader ( ) const
private

Definition at line 285 of file testframe.cpp.

◆ contentEquals()

bool contentEquals ( TestFrame const &  o) const
private

Definition at line 315 of file testframe.cpp.

References TestFrame::data().

+ Here is the call graph for this function:

◆ matchDistinction()

bool matchDistinction ( ) const
private

verify the current data was not touched since initialisation

Remarks
implemented by regenerating the data sequence deterministically, based on the Meta::distinction mark recorded in the metadata.

Definition at line 342 of file testframe.cpp.

References TestFrame::accessHeader(), and TestFrame::data64().

Referenced by TestFrame::isPristine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currStage()

TestFrame::StageOfLife currStage ( ) const
private

Definition at line 291 of file testframe.cpp.

References TestFrame::DISCARDED, TestFrame::header_, TestFrame::Meta::isPlausible(), and TestFrame::Meta::stage.

Referenced by TestFrame::isDead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeChecksum()

HashVal computeChecksum ( ) const
private
Returns
a hash checksum computed over current data content

Definition at line 353 of file testframe.cpp.

References lib::hash::combine(), and TestFrame::data().

Referenced by TestFrame::hasValidChecksum(), and TestFrame::markChecksum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasValidChecksum()

bool hasValidChecksum ( ) const
private

Definition at line 376 of file testframe.cpp.

References TestFrame::accessHeader(), TestFrame::Meta::checksum, and TestFrame::computeChecksum().

Referenced by TestFrame::isValid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ BUFFSIZ

constexpr size_t BUFFSIZ = 1024
staticconstexprprivate

Definition at line 74 of file testframe.hpp.

◆ buffer_

std::byte buffer_[sizeof(_Arr)]
private

inline storage buffer for the payload media data

Definition at line 92 of file testframe.hpp.

Referenced by TestFrame::data(), TestFrame::data(), TestFrame::data64(), and TestFrame::data64().

◆ header_

Meta header_
private

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( TestFrame const &  f1,
TestFrame const &  f2 
)
friend

Definition at line 129 of file testframe.hpp.

◆ operator!=

bool operator!= ( TestFrame const &  f1,
TestFrame const &  f2 
)
friend

Definition at line 130 of file testframe.hpp.

+ Collaboration diagram for TestFrame:

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