Lumiera  0.pre.03
»edit your freedom«
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.

Public Member Functions

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

Static Public Member Functions

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

Classes

struct  Meta
 

Friends

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

Private Types

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

Private Member Functions

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

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
 

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.

◆ 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.

Referenced by steam::engine::test::combineFrames(), and steam::engine::test::manipulateFrame().

+ Here is the caller graph for this function:

◆ isAlive()

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 416 of file testframe.cpp.

◆ 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.

Referenced by TestFrame::data().

+ Here is the caller 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.

Referenced by TestFrame::data().

+ 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.

Referenced by TestFrame::data().

+ Here is the caller graph for this function:
+ Collaboration diagram for TestFrame:

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