2011-10-31 00:13:35 +01:00
|
|
|
|
/*
|
|
|
|
|
|
TestFrame - test data frame (stub) for checking Render engine functionality
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2011, Hermann Vosseler <Ichthyostega@web.de>
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2017-02-22 01:58:49 +01:00
|
|
|
|
/** @file testframe.cpp
|
|
|
|
|
|
** Implementation of fake data frames to support unit testing
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
|
|
|
|
|
#include "lib/error.hpp"
|
2024-11-13 02:23:23 +01:00
|
|
|
|
#include "lib/random.hpp"
|
2024-11-18 23:55:30 +01:00
|
|
|
|
#include "lib/hash-standard.hpp"
|
|
|
|
|
|
#include "lib/hash-combine.hpp"
|
2024-11-05 21:23:13 +01:00
|
|
|
|
#include "steam/engine/testframe.hpp"
|
2024-11-18 02:45:37 +01:00
|
|
|
|
#include "lib/nocopy.hpp"
|
|
|
|
|
|
#include "lib/util.hpp"
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2024-11-18 02:45:37 +01:00
|
|
|
|
#include <climits>
|
2017-01-05 00:56:46 +01:00
|
|
|
|
#include <memory>
|
2011-10-31 02:20:32 +01:00
|
|
|
|
#include <vector>
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2011-11-01 03:11:43 +01:00
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2011-10-31 00:13:35 +01:00
|
|
|
|
namespace engine {
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
using util::unConst;
|
2011-11-01 03:11:43 +01:00
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
2024-11-18 02:45:37 +01:00
|
|
|
|
/** @note using a random-congruential engine to generate the payload data */
|
|
|
|
|
|
using PseudoRandom = lib::RandomSequencer<std::minstd_rand>;
|
2011-11-01 03:11:43 +01:00
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
|
|
|
|
|
namespace error = lumiera::error;
|
|
|
|
|
|
|
|
|
|
|
|
namespace { // hidden local support facilities....
|
|
|
|
|
|
|
2024-11-18 02:45:37 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Offset to set the seed values of »families« apart.
|
|
|
|
|
|
* The data in the test frames is generated from a distinctive ID-seed,
|
|
|
|
|
|
* which is controlled by the _family_ and the _seq-No_ within each family.
|
|
|
|
|
|
* The seeds for consecutive frames are spread apart by the #dataSeed,
|
|
|
|
|
|
* and the SEQUENCE_SPREAD constant acts as minimum spread. While seed
|
|
|
|
|
|
* values can wrap within the 64bit number range, this generation scheme
|
|
|
|
|
|
* makes it very unlikely that neighbouring frames end up with the same seed.
|
|
|
|
|
|
*/
|
|
|
|
|
|
const size_t SEQUENCE_SPREAD = 100;
|
|
|
|
|
|
|
|
|
|
|
|
HashVal
|
|
|
|
|
|
drawSeed (lib::Random& srcGen)
|
|
|
|
|
|
{
|
|
|
|
|
|
return srcGen.distribute(
|
|
|
|
|
|
std::uniform_int_distribution<HashVal>{SEQUENCE_SPREAD
|
|
|
|
|
|
,std::numeric_limits<HashVal>::max()-SEQUENCE_SPREAD});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @internal a static seed hash used to anchor the data distinction ID-seeds */
|
|
|
|
|
|
HashVal dataSeed{drawSeed(lib::entropyGen)};
|
|
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
/** @internal helper for generating unique test frames.
|
2024-11-18 23:55:30 +01:00
|
|
|
|
* This »discriminator« is used as a random seed when filling the test frame data buffers.
|
2024-11-18 02:45:37 +01:00
|
|
|
|
* It is generated to be very likely different on adjacent frames of the same series,
|
|
|
|
|
|
* as well as to differ to all nearby neighbouring channels.
|
2024-11-18 23:55:30 +01:00
|
|
|
|
* @note the #dataSeed hash is limited by #SEQUENCE_SPREAD to prevent „risky“ families;
|
|
|
|
|
|
* the extreme case would be dataSeed+family ≡ 0 (all frames would be equal then)
|
2011-10-31 02:20:32 +01:00
|
|
|
|
* @param seq the sequence number of the frame within the channel
|
|
|
|
|
|
* @param family the channel this frame belongs to
|
|
|
|
|
|
*/
|
|
|
|
|
|
uint64_t
|
2024-11-18 23:55:30 +01:00
|
|
|
|
generateDiscriminator(uint seq, uint family)
|
2011-10-31 02:20:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
// use the family as stepping
|
2024-11-18 02:45:37 +01:00
|
|
|
|
return (seq+1) * (dataSeed+family);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class DistinctNucleus
|
|
|
|
|
|
: public lib::SeedNucleus
|
|
|
|
|
|
, util::MoveOnly
|
|
|
|
|
|
{
|
|
|
|
|
|
uint64_t const& fixPoint_;
|
|
|
|
|
|
public:
|
|
|
|
|
|
DistinctNucleus(uint64_t const& anchor)
|
|
|
|
|
|
: fixPoint_{anchor}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
|
|
getSeed() override
|
|
|
|
|
|
{
|
|
|
|
|
|
return fixPoint_;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
/** @return a stable characteristic memory marker for the metadata record */
|
|
|
|
|
|
HashVal
|
|
|
|
|
|
stampHeader()
|
|
|
|
|
|
{
|
|
|
|
|
|
static const HashVal MARK = lib::entropyGen.hash()
|
|
|
|
|
|
| 0b1000'1000'1000'1000'1000'1000'1000'1000;
|
|
|
|
|
|
return MARK;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-18 02:45:37 +01:00
|
|
|
|
/** @internal build a PRNG starting from the referred fixed seed */
|
|
|
|
|
|
auto
|
|
|
|
|
|
buildDataGenFrom (uint64_t const& anchor)
|
|
|
|
|
|
{
|
|
|
|
|
|
DistinctNucleus seed{anchor};
|
|
|
|
|
|
return PseudoRandom{seed};
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
accessAsTestFrame (void* memoryLocation)
|
|
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (memoryLocation);
|
|
|
|
|
|
return *reinterpret_cast<TestFrame*> (memoryLocation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @internal table to hold test data frames.
|
|
|
|
|
|
* These frames are built on demand, but retained thereafter.
|
|
|
|
|
|
* Some tests might rely on the actual memory locations, using the
|
|
|
|
|
|
* test frames to simulate a real input frame data stream.
|
|
|
|
|
|
* @param CHA the maximum number of channels to expect
|
2024-11-05 21:23:13 +01:00
|
|
|
|
* @param FRA the maximum number of frames to expect per channel
|
2011-10-31 02:20:32 +01:00
|
|
|
|
* @warning choose the maximum number parameters wisely.
|
|
|
|
|
|
* We're allocating memory to hold a table of test frames
|
|
|
|
|
|
* e.g. sizeof(TestFrame) * 20channels * 100frames ≈ 2 MiB
|
|
|
|
|
|
* The table uses vectors, and thus will grow on demand,
|
|
|
|
|
|
* but this might cause existing frames to be relocated in memory;
|
|
|
|
|
|
* some tests might rely on fixed memory locations. Just be cautious!
|
|
|
|
|
|
*/
|
|
|
|
|
|
template<uint CHA, uint FRA>
|
|
|
|
|
|
struct TestFrameTable
|
2016-12-23 04:23:03 +01:00
|
|
|
|
: vector<vector<TestFrame>>
|
2011-10-31 02:20:32 +01:00
|
|
|
|
{
|
2016-12-23 04:23:03 +01:00
|
|
|
|
typedef vector<vector<TestFrame>> VECT;
|
2011-10-31 02:20:32 +01:00
|
|
|
|
|
|
|
|
|
|
TestFrameTable()
|
|
|
|
|
|
: VECT(CHA)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (uint i=0; i<CHA; ++i)
|
|
|
|
|
|
at(i).reserve(FRA);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
getFrame (uint seqNr, uint chanNr=0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (chanNr >= this->size())
|
|
|
|
|
|
{
|
|
|
|
|
|
WARN (test, "Growing table of test frames to %d channels, "
|
|
|
|
|
|
"which is > the default (%d)", chanNr, CHA);
|
|
|
|
|
|
resize(chanNr+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
ENSURE (chanNr < this->size());
|
|
|
|
|
|
vector<TestFrame>& channel = at(chanNr);
|
|
|
|
|
|
|
|
|
|
|
|
if (seqNr >= channel.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
WARN_IF (seqNr >= FRA, test,
|
|
|
|
|
|
"Growing channel #%d of test frames to %d elements, "
|
|
|
|
|
|
"which is > the default (%d)", chanNr, seqNr, FRA);
|
|
|
|
|
|
for (uint i=channel.size(); i<=seqNr; ++i)
|
2011-11-01 03:36:35 +01:00
|
|
|
|
channel.push_back (TestFrame (i,chanNr));
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
ENSURE (seqNr < channel.size());
|
|
|
|
|
|
|
|
|
|
|
|
return channel[seqNr];
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const uint INITIAL_CHAN = 20;
|
|
|
|
|
|
const uint INITIAL_FRAMES = 100;
|
|
|
|
|
|
|
|
|
|
|
|
typedef TestFrameTable<INITIAL_CHAN,INITIAL_FRAMES> TestFrames;
|
|
|
|
|
|
|
2017-01-05 00:56:46 +01:00
|
|
|
|
std::unique_ptr<TestFrames> testFrames;
|
2011-10-31 02:20:32 +01:00
|
|
|
|
|
2011-11-01 03:11:43 +01:00
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame&
|
|
|
|
|
|
accessTestFrame (uint seqNr, uint chanNr)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!testFrames) testFrames.reset (new TestFrames);
|
|
|
|
|
|
|
|
|
|
|
|
return testFrames->getFrame(seqNr,chanNr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
} // (End) hidden impl details
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
testData (uint seqNr)
|
|
|
|
|
|
{
|
|
|
|
|
|
return accessTestFrame (seqNr, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
testData (uint chanNr, uint seqNr)
|
|
|
|
|
|
{
|
|
|
|
|
|
return accessTestFrame (seqNr,chanNr);
|
|
|
|
|
|
}
|
2024-11-18 02:45:37 +01:00
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
|
2024-11-18 02:45:37 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @remark 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 \ref 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.
|
|
|
|
|
|
*/
|
2011-10-31 02:20:32 +01:00
|
|
|
|
void
|
2024-11-18 02:45:37 +01:00
|
|
|
|
TestFrame::reseed()
|
2011-10-31 02:20:32 +01:00
|
|
|
|
{
|
2024-11-18 02:45:37 +01:00
|
|
|
|
testFrames.reset();
|
|
|
|
|
|
drawSeed (lib::defaultGen);
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-01 03:11:43 +01:00
|
|
|
|
/* ===== TestFrame class ===== */
|
2011-10-31 02:20:32 +01:00
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
TestFrame::Meta::Meta (uint seq, uint family)
|
|
|
|
|
|
: _MARK_{stampHeader()}
|
|
|
|
|
|
, checksum{0}
|
|
|
|
|
|
, distinction{generateDiscriminator (seq,family)}
|
|
|
|
|
|
, stage{CREATED}
|
|
|
|
|
|
{ }
|
|
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame::~TestFrame()
|
|
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
header_.stage = DISCARDED;
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
TestFrame::TestFrame (uint seq, uint family)
|
|
|
|
|
|
: header_{seq,family}
|
2011-10-31 02:20:32 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
ASSERT (0 < header_.distinction);
|
|
|
|
|
|
header_.checksum = buildData();
|
|
|
|
|
|
ENSURE (CREATED == header_.stage);
|
|
|
|
|
|
ENSURE (isPristine());
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame::TestFrame (TestFrame const& o)
|
2024-11-18 23:55:30 +01:00
|
|
|
|
: header_{o.header_}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
data() = o.data();
|
|
|
|
|
|
header_.stage = CREATED;
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
TestFrame::operator= (TestFrame const& o)
|
|
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
if (not isAlive())
|
|
|
|
|
|
throw new error::Logic ("target TestFrame already dead or unaccessible");
|
2024-11-18 02:45:37 +01:00
|
|
|
|
if (not util::isSameAdr (this, o))
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
data() = o.data();
|
|
|
|
|
|
header_ = o.header_;
|
|
|
|
|
|
header_.stage = CREATED;
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
TestFrame::Meta&
|
|
|
|
|
|
TestFrame::accessHeader()
|
|
|
|
|
|
{
|
|
|
|
|
|
return header_;
|
|
|
|
|
|
}
|
|
|
|
|
|
TestFrame::Meta const&
|
|
|
|
|
|
TestFrame::accessHeader() const
|
|
|
|
|
|
{
|
|
|
|
|
|
///////////////////////OOO detect if valid header present and else throw
|
|
|
|
|
|
return unConst(this)->accessHeader();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame::StageOfLife
|
|
|
|
|
|
TestFrame::currStage() const
|
|
|
|
|
|
{
|
|
|
|
|
|
///////////////////////OOO detect if valid header present and then access
|
|
|
|
|
|
}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
/** @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.
|
2011-10-31 00:13:35 +01:00
|
|
|
|
*/
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isAlive (void* memLocation)
|
|
|
|
|
|
{
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame& candidate (accessAsTestFrame (memLocation));
|
|
|
|
|
|
return candidate.isSane()
|
|
|
|
|
|
&& candidate.isAlive();
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isDead (void* memLocation)
|
|
|
|
|
|
{
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame& candidate (accessAsTestFrame (memLocation));
|
|
|
|
|
|
return candidate.isSane()
|
|
|
|
|
|
&& candidate.isDead();
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::operator== (void* memLocation) const
|
|
|
|
|
|
{
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame& candidate (accessAsTestFrame (memLocation));
|
|
|
|
|
|
return candidate.isSane()
|
|
|
|
|
|
&& candidate == *this;
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::contentEquals (TestFrame const& o) const
|
|
|
|
|
|
{
|
2011-10-31 02:20:32 +01:00
|
|
|
|
for (uint i=0; i<BUFFSIZ; ++i)
|
2024-11-05 21:23:13 +01:00
|
|
|
|
if (data()[i] != o.data()[i])
|
2011-10-31 02:20:32 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
return true;
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
|
|
|
|
|
|
HashVal
|
|
|
|
|
|
TestFrame::buildData()
|
|
|
|
|
|
{
|
|
|
|
|
|
auto gen = buildDataGenFrom (accessHeader().distinction);
|
|
|
|
|
|
for (uint i=0; i<BUFFSIZ; ++i)
|
|
|
|
|
|
data()[i] = char(gen.i(CHAR_MAX));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
bool
|
2011-10-31 02:20:32 +01:00
|
|
|
|
TestFrame::verifyData() const
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
auto gen = buildDataGenFrom (accessHeader().distinction);
|
2011-10-31 02:20:32 +01:00
|
|
|
|
for (uint i=0; i<BUFFSIZ; ++i)
|
2024-11-18 02:45:37 +01:00
|
|
|
|
if (data()[i] != char(gen.i(CHAR_MAX)))
|
2011-10-31 02:20:32 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
return true;
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
HashVal
|
|
|
|
|
|
TestFrame::computeChecksum() const
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
HashVal hash{0};
|
|
|
|
|
|
////////////////////////////////////////////OOO actually compute it
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::hasValidChecksum() const
|
|
|
|
|
|
{
|
|
|
|
|
|
////////////////////////////////////////////OOO actually compute checksum and verify
|
|
|
|
|
|
}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isAlive() const
|
|
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
return (CREATED == currStage())
|
|
|
|
|
|
|| (EMITTED == currStage());
|
2011-10-31 02:20:32 +01:00
|
|
|
|
}
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isDead() const
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
return (DISCARDED == currStage());
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-31 02:20:32 +01:00
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isSane() const
|
2011-10-31 00:13:35 +01:00
|
|
|
|
{
|
2024-11-18 23:55:30 +01:00
|
|
|
|
return ( (CREATED == currStage())
|
|
|
|
|
|
||(EMITTED == currStage())
|
|
|
|
|
|
||(DISCARDED == currStage()))
|
2011-10-31 02:20:32 +01:00
|
|
|
|
&& verifyData();
|
2011-10-31 00:13:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-18 23:55:30 +01:00
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isValid() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return isSane()
|
|
|
|
|
|
and hasValidChecksum();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
TestFrame::isPristine() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return isSane()
|
|
|
|
|
|
and hasValidChecksum();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-10-31 00:13:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}} // namespace steam::engine::test
|