2007-09-03 02:33:47 +02:00
|
|
|
|
/*
|
2024-11-06 02:13:23 +01:00
|
|
|
|
NodeDevel(Test) - Render Node development and test support
|
2010-12-17 23:28:49 +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
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2024, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +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.
|
2010-12-17 23:28:49 +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
|
|
|
|
* *****************************************************************/
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
2024-04-22 23:13:55 +02:00
|
|
|
|
/** @file node-devel-test.cpp
|
2024-12-06 23:43:18 +01:00
|
|
|
|
** Unit test \ref NodeDevel_test verifies helpers for testing of render nodes.
|
2016-11-03 18:20:10 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
2008-12-18 04:47:41 +01:00
|
|
|
|
#include "lib/test/run.hpp"
|
2024-11-20 21:44:50 +01:00
|
|
|
|
#include "lib/hash-combine.hpp"
|
2024-11-28 23:41:56 +01:00
|
|
|
|
#include "lib/test/test-helper.hpp"
|
2025-01-06 19:47:51 +01:00
|
|
|
|
#include "steam/engine/node-builder.hpp"
|
|
|
|
|
|
#include "steam/engine/test-rand-ontology.hpp"
|
|
|
|
|
|
#include "steam/engine/diagnostic-buffer-provider.hpp"
|
2024-11-27 15:31:50 +01:00
|
|
|
|
#include "lib/iter-zip.hpp"
|
2024-11-06 02:13:23 +01:00
|
|
|
|
#include "lib/random.hpp"
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
2024-11-28 02:15:59 +01:00
|
|
|
|
#include <vector>
|
2025-11-15 02:00:11 +01:00
|
|
|
|
#include <array>
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
using lib::zip;
|
2024-11-28 02:15:59 +01:00
|
|
|
|
using lib::izip;
|
2025-11-15 02:00:11 +01:00
|
|
|
|
using std::array;
|
2024-11-28 02:15:59 +01:00
|
|
|
|
using std::vector;
|
2025-01-06 19:47:51 +01:00
|
|
|
|
using std::make_tuple;
|
|
|
|
|
|
using lib::test::showType;
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
namespace steam {
|
2009-08-31 00:49:08 +02:00
|
|
|
|
namespace engine{
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
2024-11-06 02:13:23 +01:00
|
|
|
|
namespace {
|
|
|
|
|
|
/** uninitialised local storage that can be passed
|
|
|
|
|
|
* as working buffer and accessed as TestFrame */
|
|
|
|
|
|
struct Buffer
|
|
|
|
|
|
: util::NonCopyable
|
|
|
|
|
|
{
|
|
|
|
|
|
alignas(TestFrame)
|
2025-11-15 02:00:11 +01:00
|
|
|
|
array<std::byte, sizeof(TestFrame)> storage{}; //zero-init
|
2024-11-06 02:13:23 +01:00
|
|
|
|
|
2024-11-20 21:44:50 +01:00
|
|
|
|
operator TestFrame* () { return std::launder (reinterpret_cast<TestFrame* > (&storage)); }
|
|
|
|
|
|
TestFrame* operator->() { return std::launder (reinterpret_cast<TestFrame* > (&storage)); }
|
|
|
|
|
|
TestFrame& operator* () { return * std::launder (reinterpret_cast<TestFrame* > (&storage)); }
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame&
|
|
|
|
|
|
buildData (uint seq=0, uint family=0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return * new(&storage) TestFrame{seq,family};
|
|
|
|
|
|
}
|
2024-11-06 02:13:23 +01:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2009-08-31 00:49:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-24 23:06:36 +02:00
|
|
|
|
/***************************************************************//**
|
2024-11-06 02:13:23 +01:00
|
|
|
|
* @test verify support for developing Render Node functionality.
|
2025-02-11 01:10:25 +01:00
|
|
|
|
* - raw processing functions to generate and manipulate
|
|
|
|
|
|
* \ref TestFrame data, including hash chaining.
|
|
|
|
|
|
* - a »TestRand-Ontology«, which is a test helper framework,
|
|
|
|
|
|
* and mimics a real _Domain Ontology_ (as would be accessible
|
|
|
|
|
|
* through the adapter plug-in of a specific media handling library.
|
|
|
|
|
|
* - some convenience shortcuts to build test-nodes
|
2009-08-31 00:49:08 +02:00
|
|
|
|
*/
|
2024-04-22 23:13:55 +02:00
|
|
|
|
class NodeDevel_test : public Test
|
2007-09-03 02:33:47 +02:00
|
|
|
|
{
|
2024-11-06 02:13:23 +01:00
|
|
|
|
virtual void
|
|
|
|
|
|
run (Arg)
|
|
|
|
|
|
{
|
2024-11-12 22:35:54 +01:00
|
|
|
|
seedRand();
|
2024-11-20 21:44:50 +01:00
|
|
|
|
TestFrame::reseed();
|
2024-11-06 02:13:23 +01:00
|
|
|
|
|
|
|
|
|
|
processing_generateFrame();
|
|
|
|
|
|
processing_generateMultichan();
|
2024-11-28 02:15:59 +01:00
|
|
|
|
processing_duplicateMultichan();
|
|
|
|
|
|
processing_manipulateMultichan();
|
2024-11-20 21:44:50 +01:00
|
|
|
|
processing_manipulateFrame();
|
2024-11-27 15:31:50 +01:00
|
|
|
|
processing_combineFrames();
|
2024-11-28 23:41:56 +01:00
|
|
|
|
|
|
|
|
|
|
testRand_simpleUsage();
|
2025-02-09 18:04:39 +01:00
|
|
|
|
testRand_buildFilterNode();
|
|
|
|
|
|
testRand_buildMixNode();
|
2024-11-06 02:13:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test function to generate random test data frames
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_generateFrame()
|
|
|
|
|
|
{
|
2024-11-12 22:35:54 +01:00
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
2024-11-06 02:13:23 +01:00
|
|
|
|
|
|
|
|
|
|
Buffer buff;
|
|
|
|
|
|
CHECK (not buff->isSane());
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::generateFrame (buff, frameNr, flavour);
|
2024-11-06 02:13:23 +01:00
|
|
|
|
CHECK ( buff->isSane());
|
2024-11-28 02:15:59 +01:00
|
|
|
|
CHECK ( buff->isPristine());
|
2024-11-06 02:13:23 +01:00
|
|
|
|
CHECK (*buff == TestFrame(frameNr,flavour));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @test function to generate an array of random test data frames
|
|
|
|
|
|
* for consecutive channels
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_generateMultichan()
|
2009-08-31 00:49:08 +02:00
|
|
|
|
{
|
2024-11-12 22:35:54 +01:00
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
2024-11-06 02:13:23 +01:00
|
|
|
|
|
2024-11-12 22:35:54 +01:00
|
|
|
|
uint channels = 1 + rani(50);
|
2024-11-06 02:13:23 +01:00
|
|
|
|
CHECK (1 <= channels and channels <= 50);
|
|
|
|
|
|
|
2024-11-28 02:15:59 +01:00
|
|
|
|
Buffer buff[50];
|
2024-11-06 02:13:23 +01:00
|
|
|
|
for (uint i=0; i<channels; ++i)
|
2024-11-28 02:15:59 +01:00
|
|
|
|
CHECK (not buff[i]->isSane());
|
2024-11-06 02:13:23 +01:00
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::generateMultichan (buff[0], channels, frameNr, flavour);
|
2024-11-06 02:13:23 +01:00
|
|
|
|
for (uint i=0; i<channels; ++i)
|
|
|
|
|
|
{
|
2024-11-28 02:15:59 +01:00
|
|
|
|
CHECK (buff[i]->isPristine());
|
|
|
|
|
|
CHECK (*(buff[i]) == TestFrame(frameNr,flavour+i));
|
2024-11-06 02:13:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-20 21:44:50 +01:00
|
|
|
|
|
2024-11-28 02:15:59 +01:00
|
|
|
|
|
|
|
|
|
|
/** @test clone copy of multichannel test data */
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_duplicateMultichan()
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
uint channels = 1 + rani(50);
|
|
|
|
|
|
Buffer srcBuff[50];
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::generateMultichan (srcBuff[0], channels, frameNr, flavour);
|
2024-11-28 02:15:59 +01:00
|
|
|
|
|
|
|
|
|
|
Buffer clone[50];
|
|
|
|
|
|
for (uint i=0; i<channels; ++i)
|
|
|
|
|
|
CHECK (not clone[i]->isSane());
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::duplicateMultichan (clone[0],srcBuff[0], channels);
|
2024-11-28 02:15:59 +01:00
|
|
|
|
for (uint i=0; i<channels; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
CHECK (clone[i]->isPristine());
|
|
|
|
|
|
CHECK (*(clone[i]) == *(srcBuff[i]));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test multichannel data hash-chain manipulation
|
|
|
|
|
|
* - use multichannel pseudo random input data
|
|
|
|
|
|
* - store away a clone copy before manipulation
|
|
|
|
|
|
* - the #manipulateMultichan() operates in-place in the buffers
|
|
|
|
|
|
* - each buffer has been marked with a new checksum afterwards
|
|
|
|
|
|
* - and each buffer now differs from original state
|
|
|
|
|
|
* - verify that corresponding data points over all channels
|
|
|
|
|
|
* have been linked by a hashcode-chain, seeded with the `param`
|
|
|
|
|
|
* and then consecutively hashing in data from each channel.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_manipulateMultichan()
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
uint channels = 1 + rani(50);
|
|
|
|
|
|
Buffer buff[50], refData[50];
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::generateMultichan (buff[0], channels, frameNr, flavour);
|
2024-11-28 02:15:59 +01:00
|
|
|
|
// stash away a copy of the test data for verification
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::duplicateMultichan(refData[0],buff[0], channels);
|
2024-11-28 02:15:59 +01:00
|
|
|
|
|
|
|
|
|
|
for (uint c=0; c<channels; ++c)
|
|
|
|
|
|
CHECK (buff[c]->isPristine());
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t param = defaultGen.u64();
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::manipulateMultichan(buff[0], channels, param);
|
2024-11-28 02:15:59 +01:00
|
|
|
|
|
|
|
|
|
|
const uint SIZ = buff[0]->data64().size();
|
|
|
|
|
|
vector<uint64_t> xlink(SIZ, param); // temporary storage for verifying the hash-chain
|
|
|
|
|
|
for (uint c=0; c<channels; ++c)
|
|
|
|
|
|
{
|
|
|
|
|
|
CHECK (buff[c]->isSane()); // checksum matches
|
|
|
|
|
|
CHECK (not buff[c]->isPristine()); // data was indeed changed
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (*(buff[c]) != *(refData[c]));
|
|
|
|
|
|
|
|
|
|
|
|
for (auto& [i, link] : izip(xlink))
|
|
|
|
|
|
{
|
|
|
|
|
|
auto const& refPoint = refData[c]->data64()[i];
|
|
|
|
|
|
lib::hash::combine (link, refPoint);
|
|
|
|
|
|
CHECK (link != refPoint);
|
|
|
|
|
|
CHECK (link == buff[c]->data64()[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @test function to apply a numeric computation to test data frames;
|
|
|
|
|
|
* @remark here basically the same hash-chaining is used as for #manipulateMultichan,
|
|
|
|
|
|
* but only one hash-chain per data point is used and output is written to a different buffer.
|
2024-11-20 21:44:50 +01:00
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_manipulateFrame()
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
|
|
|
|
|
|
Buffer iBuff, oBuff;
|
|
|
|
|
|
iBuff.buildData(frameNr,flavour);
|
|
|
|
|
|
oBuff.buildData(frameNr,flavour);
|
|
|
|
|
|
CHECK (iBuff->isPristine());
|
2024-11-27 15:31:50 +01:00
|
|
|
|
CHECK (oBuff->isPristine());
|
2024-11-20 21:44:50 +01:00
|
|
|
|
|
|
|
|
|
|
uint64_t param = defaultGen.u64();
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::manipulateFrame (oBuff, iBuff, param);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
CHECK ( oBuff->isValid());
|
|
|
|
|
|
CHECK (not oBuff->isPristine());
|
|
|
|
|
|
CHECK ( iBuff->isPristine());
|
|
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
for (auto [iDat,oDat] : zip (iBuff->data64()
|
|
|
|
|
|
,oBuff->data64()))
|
2024-11-20 21:44:50 +01:00
|
|
|
|
{
|
2024-11-27 15:31:50 +01:00
|
|
|
|
CHECK (oDat != iDat);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
uint64_t feed = param;
|
2024-11-27 15:31:50 +01:00
|
|
|
|
lib::hash::combine (feed, iDat);
|
|
|
|
|
|
CHECK (feed != param);
|
|
|
|
|
|
CHECK (feed != iDat);
|
|
|
|
|
|
CHECK (feed == oDat);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
// can also process in-place
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::manipulateFrame (iBuff, iBuff, param);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
CHECK (not iBuff->isPristine());
|
|
|
|
|
|
CHECK ( iBuff->isValid());
|
|
|
|
|
|
CHECK (*iBuff == *oBuff); // second invocation exactly reproduced data from first invocation
|
|
|
|
|
|
}
|
2024-11-27 15:31:50 +01:00
|
|
|
|
|
|
|
|
|
|
/** @test function to mix two test data frames
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
processing_combineFrames()
|
|
|
|
|
|
{
|
|
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
|
|
|
|
|
|
Buffer i1Buff, i2Buff, oBuff;
|
|
|
|
|
|
i1Buff.buildData(frameNr,flavour+0);
|
|
|
|
|
|
i2Buff.buildData(frameNr,flavour+1);
|
|
|
|
|
|
oBuff.buildData();
|
|
|
|
|
|
CHECK (i1Buff->isPristine());
|
|
|
|
|
|
CHECK (i2Buff->isPristine());
|
|
|
|
|
|
CHECK (oBuff->isPristine());
|
|
|
|
|
|
|
|
|
|
|
|
double mix = defaultGen.uni();
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::combineFrames (oBuff, i1Buff, i2Buff, mix);
|
2024-11-27 15:31:50 +01:00
|
|
|
|
CHECK ( oBuff->isValid());
|
|
|
|
|
|
CHECK (not oBuff->isPristine());
|
|
|
|
|
|
CHECK ( i1Buff->isPristine());
|
|
|
|
|
|
CHECK ( i2Buff->isPristine());
|
|
|
|
|
|
|
|
|
|
|
|
for (auto [oDat,i1Dat,i2Dat] : zip (oBuff->data()
|
|
|
|
|
|
,i1Buff->data()
|
|
|
|
|
|
,i2Buff->data()))
|
|
|
|
|
|
CHECK (oDat == std::lround((1-mix)*i1Dat + mix*i2Dat));
|
|
|
|
|
|
|
|
|
|
|
|
// can also process in-place
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ont::combineFrames (i1Buff, i1Buff, i2Buff, mix);
|
2024-11-27 15:31:50 +01:00
|
|
|
|
CHECK (not i1Buff->isPristine());
|
|
|
|
|
|
CHECK ( i1Buff->isValid());
|
|
|
|
|
|
CHECK (*i1Buff == *oBuff); // second invocation exactly reproduced data from first invocation
|
|
|
|
|
|
}
|
2024-11-28 23:41:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
2024-12-05 23:58:22 +01:00
|
|
|
|
|
2024-11-28 23:41:56 +01:00
|
|
|
|
/** @test demonstrate simple usage of test-render setup
|
|
|
|
|
|
* - access the TestRandOntology as singleton
|
|
|
|
|
|
* - create a Spec record
|
2024-12-05 23:58:22 +01:00
|
|
|
|
* - retrieve a functor bound suitably to invoke
|
|
|
|
|
|
* data processing code from the TestRandOntology
|
2024-11-28 23:41:56 +01:00
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
testRand_simpleUsage()
|
|
|
|
|
|
{
|
|
|
|
|
|
auto spec = testRand().setupGenerator();
|
|
|
|
|
|
CHECK (spec.PROTO == "generate-TestFrame"_expect);
|
2025-01-06 22:00:29 +01:00
|
|
|
|
|
|
|
|
|
|
// generate a binding as processing-functor
|
2025-01-06 19:47:51 +01:00
|
|
|
|
auto procFun = spec.makeFun();
|
|
|
|
|
|
using Sig = lib::meta::_Fun<decltype(procFun)>::Sig;
|
|
|
|
|
|
CHECK (showType<Sig>() == "void (tuple<ulong, uint>, engine::test::TestFrame*)"_expect);
|
|
|
|
|
|
|
2025-01-06 22:00:29 +01:00
|
|
|
|
// Behaves identical to processing_generateFrame() — see above...
|
2025-01-06 19:47:51 +01:00
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
|
|
|
|
|
|
Buffer buff;
|
|
|
|
|
|
CHECK (not buff->isSane());
|
|
|
|
|
|
|
|
|
|
|
|
procFun (make_tuple (frameNr,flavour), buff);
|
|
|
|
|
|
CHECK ( buff->isSane());
|
|
|
|
|
|
CHECK ( buff->isPristine());
|
|
|
|
|
|
CHECK (*buff == TestFrame(frameNr,flavour));
|
|
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
// Build a node using this processing-functor...
|
2025-01-06 22:00:29 +01:00
|
|
|
|
ProcNode node{prepareNode(spec.nodeID())
|
2025-01-06 19:47:51 +01:00
|
|
|
|
.preparePort()
|
2025-01-06 22:00:29 +01:00
|
|
|
|
.invoke(spec.procID(), procFun)
|
2025-01-06 19:47:51 +01:00
|
|
|
|
.setParam(frameNr,flavour)
|
|
|
|
|
|
.completePort()
|
|
|
|
|
|
.build()};
|
|
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
CHECK (watch(node).isSrc());
|
|
|
|
|
|
CHECK (watch(node).getNodeSpec() == "Test:generate-◎"_expect);
|
|
|
|
|
|
CHECK (watch(node).getPortSpec(0) == "generate(TestFrame)"_expect);
|
2025-01-06 19:47:51 +01:00
|
|
|
|
|
|
|
|
|
|
BufferProvider& provider = DiagnosticBufferProvider::build();
|
|
|
|
|
|
BuffHandle buffHandle = provider.lockBuffer (provider.getDescriptorFor(sizeof(TestFrame)));
|
|
|
|
|
|
uint port{0};
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (not buffHandle.accessAs<TestFrame>().isSane());
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger Node invocation...
|
|
|
|
|
|
buffHandle = node.pull (port, buffHandle, Time::ZERO, ProcessKey{0});
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame& result = buffHandle.accessAs<TestFrame>();
|
|
|
|
|
|
CHECK (result.isSane());
|
|
|
|
|
|
CHECK (result.isPristine());
|
|
|
|
|
|
CHECK (result == *buff);
|
|
|
|
|
|
buffHandle.release();
|
2024-11-28 23:41:56 +01:00
|
|
|
|
}
|
2025-02-09 18:04:39 +01:00
|
|
|
|
|
2025-02-09 23:05:41 +01:00
|
|
|
|
/** shortcut to simplify the following test cases */
|
|
|
|
|
|
static ProcNode
|
|
|
|
|
|
makeSrcNode (ont::FraNo frameNr, ont::Flavr flavour)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto spec = testRand().setupGenerator();
|
|
|
|
|
|
return prepareNode(spec.nodeID())
|
|
|
|
|
|
.preparePort()
|
|
|
|
|
|
.invoke(spec.procID(), spec.makeFun())
|
|
|
|
|
|
.setParam(frameNr,flavour)
|
|
|
|
|
|
.completePort()
|
|
|
|
|
|
.build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
|
2025-02-10 03:41:05 +01:00
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
/** @test use the »TestRand«-framework to setup a filter node
|
2025-02-10 03:41:05 +01:00
|
|
|
|
* - implementation is backed by the ont::manipulateFrame() function
|
|
|
|
|
|
* - it thus operates on \ref TestFrame data and results can be verified
|
|
|
|
|
|
* - the generated spec-recod provides a processing-functor binding and node-spec
|
|
|
|
|
|
* - can build and wire a Node processing chain with a source node and a »filter«
|
|
|
|
|
|
* node based on this data manipulation, which exactly reproduces the data
|
|
|
|
|
|
* content generated by the stand-alone invocation.
|
|
|
|
|
|
* @remark such a test-setup thus not only allows to prove that the function was invoked,
|
|
|
|
|
|
* but also the order in which the processing took place, due to hash-chaining
|
|
|
|
|
|
* applied to every single data word in the `TestFrame` buffer.
|
|
|
|
|
|
* @see NodeLink_test::trigger_node_port_invocation()
|
2025-02-09 18:04:39 +01:00
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
testRand_buildFilterNode()
|
|
|
|
|
|
{
|
|
|
|
|
|
auto spec = testRand().setupManipulator();
|
|
|
|
|
|
CHECK (spec.PROTO == "manipulate-TestFrame"_expect);
|
|
|
|
|
|
|
|
|
|
|
|
// generate a binding as processing-functor
|
|
|
|
|
|
auto procFun = spec.makeFun();
|
|
|
|
|
|
using Sig = lib::meta::_Fun<decltype(procFun)>::Sig;
|
|
|
|
|
|
CHECK (showType<Sig>() == "void (ulong, engine::test::TestFrame const*, engine::test::TestFrame*)"_expect);
|
|
|
|
|
|
|
|
|
|
|
|
// Results can be verified by ont::manipulateFrame() — see above
|
2025-02-09 23:05:41 +01:00
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
uint64_t param = defaultGen.u64();
|
|
|
|
|
|
|
|
|
|
|
|
Buffer buff;
|
|
|
|
|
|
buff.buildData(frameNr,flavour);
|
|
|
|
|
|
CHECK (buff->isPristine());
|
|
|
|
|
|
|
|
|
|
|
|
// Invoke the processing-functor directly
|
|
|
|
|
|
procFun (param, buff,buff);
|
|
|
|
|
|
CHECK ( buff->isValid());
|
|
|
|
|
|
CHECK (not buff->isPristine());
|
|
|
|
|
|
HashVal checksum = buff->markChecksum();
|
|
|
|
|
|
|
|
|
|
|
|
// reproduce the same checksum...
|
|
|
|
|
|
buff.buildData(frameNr,flavour);
|
|
|
|
|
|
CHECK (buff->isPristine());
|
2025-02-10 22:48:31 +01:00
|
|
|
|
CHECK (checksum != buff->getChecksum());
|
2025-02-09 23:05:41 +01:00
|
|
|
|
ont::manipulateFrame (buff, buff, param);
|
2025-02-10 22:48:31 +01:00
|
|
|
|
CHECK (checksum == buff->getChecksum());
|
2025-02-09 23:05:41 +01:00
|
|
|
|
|
|
|
|
|
|
// Build a node using this processing-functor...
|
|
|
|
|
|
ProcNode nSrc = makeSrcNode (frameNr,flavour);
|
|
|
|
|
|
ProcNode nFilt{prepareNode(spec.nodeID())
|
|
|
|
|
|
.preparePort()
|
|
|
|
|
|
.invoke(spec.procID(), procFun)
|
|
|
|
|
|
.setParam(param)
|
|
|
|
|
|
.connectLead(nSrc)
|
|
|
|
|
|
.completePort()
|
|
|
|
|
|
.build()};
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (watch(nSrc).isSrc());
|
|
|
|
|
|
CHECK (not watch(nFilt).isSrc());
|
2025-02-10 03:41:05 +01:00
|
|
|
|
CHECK (watch(nSrc).getNodeSpec() == "Test:generate-◎"_expect );
|
|
|
|
|
|
CHECK (watch(nFilt).getNodeSpec() == "Test:manipulate◁—Test:generate-◎"_expect );
|
2025-02-19 19:37:55 +01:00
|
|
|
|
CHECK (watch(nFilt).getPortSpec(0) == "manipulate(TestFrame)(TestFrame)"_expect );
|
2025-02-10 03:41:05 +01:00
|
|
|
|
|
|
|
|
|
|
// prepare to invoke this Node chain...
|
|
|
|
|
|
BufferProvider& provider = DiagnosticBufferProvider::build();
|
|
|
|
|
|
BuffHandle buffHandle = provider.lockBuffer (provider.getDescriptorFor(sizeof(TestFrame)));
|
|
|
|
|
|
uint port{0};
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (not buffHandle.accessAs<TestFrame>().isValid());
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger Node invocation...
|
|
|
|
|
|
buffHandle = nFilt.pull (port, buffHandle, Time::ZERO, ProcessKey{0});
|
|
|
|
|
|
|
|
|
|
|
|
TestFrame& result = buffHandle.accessAs<TestFrame>();
|
|
|
|
|
|
CHECK ( result.isValid());
|
|
|
|
|
|
CHECK (not result.isPristine());
|
|
|
|
|
|
CHECK (result == *buff);
|
|
|
|
|
|
buffHandle.release();
|
2025-02-09 18:04:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-10 22:48:31 +01:00
|
|
|
|
|
2025-02-09 18:04:39 +01:00
|
|
|
|
/** @test use the »TestRand«-framework to setup a two-chain mixer node
|
2025-02-10 22:48:31 +01:00
|
|
|
|
* - demonstrate convenience setup to package the ont::combineFrames() as »mix« Node
|
|
|
|
|
|
* - this time, we need two source chains, both generating \ref TestFrame data
|
|
|
|
|
|
* - complete processing with all steps can be verified by performing similar
|
|
|
|
|
|
* computations directly and comparing the result checksum.
|
2025-02-09 18:04:39 +01:00
|
|
|
|
*/
|
|
|
|
|
|
void
|
|
|
|
|
|
testRand_buildMixNode()
|
|
|
|
|
|
{
|
2025-02-10 22:48:31 +01:00
|
|
|
|
auto spec = testRand().setupCombinator();
|
|
|
|
|
|
CHECK (spec.PROTO == "combine-TestFrame"_expect);
|
|
|
|
|
|
|
|
|
|
|
|
// generate a binding as processing-functor
|
|
|
|
|
|
auto procFun = spec.makeFun();
|
|
|
|
|
|
using Sig = lib::meta::_Fun<decltype(procFun)>::Sig;
|
|
|
|
|
|
CHECK (showType<Sig>() == "void (double, array<engine::test::TestFrame const*, 2ul>, "
|
|
|
|
|
|
"engine::test::TestFrame*)"_expect); //^^/////////////////TICKET #1391 needlessly rendered as `long`
|
|
|
|
|
|
size_t frameNr = defaultGen.u64();
|
|
|
|
|
|
uint flavour = defaultGen.u64();
|
|
|
|
|
|
double mix = defaultGen.uni();
|
|
|
|
|
|
|
|
|
|
|
|
// Build node graph to combine two chains
|
|
|
|
|
|
ProcNode nS1 = makeSrcNode (frameNr,flavour+0);
|
|
|
|
|
|
ProcNode nS2 = makeSrcNode (frameNr,flavour+1);
|
|
|
|
|
|
ProcNode nMix{prepareNode(spec.nodeID())
|
|
|
|
|
|
.preparePort()
|
|
|
|
|
|
.invoke(spec.procID(), procFun)
|
|
|
|
|
|
.setParam(mix)
|
|
|
|
|
|
.connectLead(nS1)
|
|
|
|
|
|
.connectLead(nS2)
|
|
|
|
|
|
.completePort()
|
|
|
|
|
|
.build()};
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (not watch(nMix).isSrc());
|
|
|
|
|
|
CHECK (watch(nS1).getNodeSpec() == "Test:generate-◎"_expect );
|
|
|
|
|
|
CHECK (watch(nS2).getNodeSpec() == "Test:generate-◎"_expect );
|
|
|
|
|
|
CHECK (watch(nMix).getNodeSpec() == "Test:combine┉┉{Test:generate}"_expect );
|
2025-02-19 19:37:55 +01:00
|
|
|
|
CHECK (watch(nMix).getPortSpec(0) == "combine(TestFrame/2)(TestFrame)"_expect );
|
2025-02-10 22:48:31 +01:00
|
|
|
|
|
|
|
|
|
|
// prepare to invoke this Node chain...
|
|
|
|
|
|
BufferProvider& provider = DiagnosticBufferProvider::build();
|
|
|
|
|
|
BuffHandle buffHandle = provider.lockBuffer (provider.getDescriptorFor(sizeof(TestFrame)));
|
|
|
|
|
|
CHECK (not buffHandle.accessAs<TestFrame>().isValid());
|
|
|
|
|
|
uint port{0};
|
|
|
|
|
|
|
|
|
|
|
|
// Trigger Node invocation...
|
|
|
|
|
|
buffHandle = nMix.pull (port, buffHandle, Time::ZERO, ProcessKey{0});
|
|
|
|
|
|
|
|
|
|
|
|
CHECK (buffHandle.accessAs<TestFrame>().isValid());
|
|
|
|
|
|
HashVal checksum = buffHandle.accessAs<TestFrame>().getChecksum();
|
|
|
|
|
|
buffHandle.release();
|
|
|
|
|
|
|
|
|
|
|
|
// verify the result data by reproducing it through direct computation
|
|
|
|
|
|
Buffer bu1, bu2;
|
|
|
|
|
|
bu1.buildData(frameNr,flavour+0);
|
|
|
|
|
|
bu2.buildData(frameNr,flavour+1);
|
|
|
|
|
|
ont::combineFrames (bu1, bu1, bu2, mix);
|
|
|
|
|
|
CHECK (bu1->getChecksum() == checksum);
|
2025-02-09 18:04:39 +01:00
|
|
|
|
}
|
2009-08-31 00:49:08 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Register this test class... */
|
2024-04-22 23:13:55 +02:00
|
|
|
|
LAUNCHER (NodeDevel_test, "unit node");
|
2009-08-31 00:49:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-15 23:55:13 +01:00
|
|
|
|
}}} // namespace steam::engine::test
|