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
|
|
|
|
|
|
** unit test \ref NodeDevel_test
|
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-06 02:13:23 +01:00
|
|
|
|
#include "steam/engine/test-rand-ontology.hpp" ///////////TODO
|
|
|
|
|
|
#include "lib/test/diagnostic-output.hpp"/////////////////TODO
|
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"
|
2008-12-18 04:47:41 +01:00
|
|
|
|
//#include "lib/util.hpp"
|
2007-09-03 02:33:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
using lib::zip;
|
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)
|
|
|
|
|
|
std::byte storage[sizeof(TestFrame)];
|
|
|
|
|
|
|
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.
|
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-20 21:44:50 +01:00
|
|
|
|
processing_manipulateFrame();
|
2024-11-27 15:31:50 +01:00
|
|
|
|
processing_combineFrames();
|
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());
|
|
|
|
|
|
|
|
|
|
|
|
generateFrame (buff, frameNr, flavour);
|
|
|
|
|
|
CHECK ( buff->isSane());
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
Buffer buffs[50];
|
|
|
|
|
|
for (uint i=0; i<channels; ++i)
|
|
|
|
|
|
CHECK (not buffs[i]->isSane());
|
|
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
generateMultichan (buffs[0], channels, frameNr, flavour);
|
2024-11-06 02:13:23 +01:00
|
|
|
|
for (uint i=0; i<channels; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
CHECK (buffs[i]->isSane());
|
|
|
|
|
|
CHECK (*(buffs[i]) == TestFrame(frameNr,flavour+i));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-20 21:44:50 +01:00
|
|
|
|
|
|
|
|
|
|
/** @test function to apply a numeric computation to test data frames
|
|
|
|
|
|
*/
|
|
|
|
|
|
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();
|
|
|
|
|
|
manipulateFrame (oBuff, iBuff, param);
|
|
|
|
|
|
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
|
|
|
|
|
|
manipulateFrame (iBuff, iBuff, param);
|
|
|
|
|
|
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();
|
|
|
|
|
|
combineFrames (oBuff, i1Buff, i2Buff, mix);
|
|
|
|
|
|
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
|
|
|
|
|
|
combineFrames (i1Buff, i1Buff, i2Buff, mix);
|
|
|
|
|
|
CHECK (not i1Buff->isPristine());
|
|
|
|
|
|
CHECK ( i1Buff->isValid());
|
|
|
|
|
|
CHECK (*i1Buff == *oBuff); // second invocation exactly reproduced data from first invocation
|
|
|
|
|
|
}
|
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
|