Library: Testsuite maintenance
- SchedulerStress_test simply takes too long to complete (~4 min) and is thus aborted by the testrunner. Add a switch to allow for a quick smoke test. - SchedulerCommutator_test aborts due to an unresolved design problem, which I marked as failure - add some convenience methods for passing arguments to tests
This commit is contained in:
parent
bf41474004
commit
39d614f55f
15 changed files with 73 additions and 67 deletions
|
|
@ -22,13 +22,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file run.hpp
|
/** @file run.hpp
|
||||||
** Simple test class runner. Allows for writing unit tests as subclass of
|
** Simplistic test class runner. Allows for writing unit tests as subclass of
|
||||||
** test::Test . They may be installed for automatic invocation through test::Suite
|
** test::Test . They may be installed for automatic invocation through test::Suite
|
||||||
** by defining a Launcher instance, which can be done conveniently by the macro LAUNCHER
|
** by defining a Launcher instance, which can be done conveniently by the macro LAUNCHER
|
||||||
**
|
**
|
||||||
** @see HelloWorld_test
|
** @see HelloWorld_test
|
||||||
** @see test::Suite
|
** @see test::Suite
|
||||||
** @see testrunner.cpp
|
** @see testrunner.cpp
|
||||||
|
** @see random.hpp
|
||||||
** @see main.cpp
|
** @see main.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ namespace test {
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
typedef std::vector<string> & Arg;
|
using Arg = std::vector<string> &;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,11 +63,13 @@ namespace test {
|
||||||
class Test
|
class Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Test() = default;
|
virtual ~Test() = default; ///< this is an interface
|
||||||
virtual void run(Arg arg) = 0;
|
virtual void run(Arg arg) = 0;
|
||||||
|
|
||||||
void seedRand();
|
void seedRand(); ///< draw a new random seed from a common nucleus, and re-seed the default-Gen.
|
||||||
lib::Random makeRandGen();
|
lib::Random makeRandGen(); ///< build a dedicated new RandomGen, seeded from the default-Gen
|
||||||
|
static string firstTok (Arg); ///< conveniently pick the first token from the argument line
|
||||||
|
static uint firstVal (Arg, uint =1); ///< conveniently use some number given as argument, with optional default
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,7 +112,7 @@ namespace test {
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
|
|
||||||
// make them global for convenience
|
// make those global for convenience....
|
||||||
using ::test::Arg;
|
using ::test::Arg;
|
||||||
using ::test::Test;
|
using ::test::Test;
|
||||||
using ::test::Launch;
|
using ::test::Launch;
|
||||||
|
|
@ -125,4 +128,4 @@ using lib::defaultGen;
|
||||||
Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
|
Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif /*TESTHELPER_RUN_H*/
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ namespace test {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** draw a new random seed from a common nucleus, and re-seed the default-Gen. */
|
|
||||||
void
|
void
|
||||||
Test::seedRand()
|
Test::seedRand()
|
||||||
{
|
{
|
||||||
|
|
@ -223,7 +223,6 @@ namespace test {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** build a dedicated new RandomGen, seeded from the default-Gen */
|
|
||||||
Random
|
Random
|
||||||
Test::makeRandGen()
|
Test::makeRandGen()
|
||||||
{
|
{
|
||||||
|
|
@ -231,6 +230,22 @@ namespace test {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint
|
||||||
|
Test::firstVal (Arg arg, uint someNumber)
|
||||||
|
{
|
||||||
|
if (not isnil(arg))
|
||||||
|
someNumber = boost::lexical_cast<uint> (arg[1]); // may throw
|
||||||
|
return someNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Test::firstTok (Arg arg)
|
||||||
|
{
|
||||||
|
return isnil(arg)? util::BOTTOM_INDICATOR
|
||||||
|
: arg[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** run all testcases contained in this Suite.
|
/** run all testcases contained in this Suite.
|
||||||
* The first argument in the commandline, if present,
|
* The first argument in the commandline, if present,
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ END
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST "Scheduler Performance" SchedulerStress_test <<END
|
TEST "Scheduler Performance" SchedulerStress_test quick <<END
|
||||||
return: 0
|
return: 0
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,7 @@ namespace test{
|
||||||
virtual void
|
virtual void
|
||||||
run(Arg arg)
|
run(Arg arg)
|
||||||
{
|
{
|
||||||
uint num= isnil(arg)? 1 : lexical_cast<uint>(arg[1]);
|
uint num{firstVal (arg)};
|
||||||
|
|
||||||
cout << _Fmt("using the Singleton should create TargetObj(%d)...\n") % num;
|
cout << _Fmt("using the Singleton should create TargetObj(%d)...\n") % num;
|
||||||
|
|
||||||
Interface::setCountParam(num);
|
Interface::setCountParam(num);
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ namespace test{
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
uint num= isnil(arg)? 1 : lexical_cast<uint>(arg[1]);
|
uint num{firstVal (arg)};
|
||||||
|
|
||||||
Depend<TargetObj> singleton;
|
Depend<TargetObj> singleton;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ namespace test {
|
||||||
*/
|
*/
|
||||||
class RenderSegment_test : public Test
|
class RenderSegment_test : public Test
|
||||||
{
|
{
|
||||||
virtual void run(Arg arg)
|
virtual void
|
||||||
|
run (Arg)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("complete render process for a given test segment of the Session");
|
UNIMPLEMENTED ("complete render process for a given test segment of the Session");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,7 @@ namespace test {
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
int num= isnil(arg)? 1 : lexical_cast<int> (arg[1]);
|
uint num{firstVal (arg)};
|
||||||
|
|
||||||
for ( ; 0 < num-- ; )
|
for ( ; 0 < num-- ; )
|
||||||
greeting();
|
greeting();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,6 @@ namespace test{
|
||||||
cout << "-----"<<STRINGIFY(_F_NAME_)<<"---" << util::typeStr<_F_TYPE_>() << endl;
|
cout << "-----"<<STRINGIFY(_F_NAME_)<<"---" << util::typeStr<_F_TYPE_>() << endl;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
uint NUM_ELMS = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,11 +85,12 @@ namespace test{
|
||||||
*/
|
*/
|
||||||
class IterAdapterSTL_test : public Test
|
class IterAdapterSTL_test : public Test
|
||||||
{
|
{
|
||||||
|
uint NUM_ELMS{0};
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
|
NUM_ELMS = firstVal (arg, 10);
|
||||||
|
|
||||||
checkDistinctValIter();
|
checkDistinctValIter();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,8 @@ namespace test{
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
/**
|
||||||
uint NUM_ELMS = 10;
|
* example of simply wrapping an STL container
|
||||||
|
|
||||||
/** example of simply wrapping an STL container
|
|
||||||
* and exposing a range as Lumiera Forward Iterator
|
* and exposing a range as Lumiera Forward Iterator
|
||||||
*/
|
*/
|
||||||
struct WrappedVector
|
struct WrappedVector
|
||||||
|
|
@ -192,11 +190,12 @@ namespace test{
|
||||||
*/
|
*/
|
||||||
class IterAdapter_test : public Test
|
class IterAdapter_test : public Test
|
||||||
{
|
{
|
||||||
|
uint NUM_ELMS{0};
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
|
NUM_ELMS = firstVal (arg, 10);
|
||||||
|
|
||||||
useSimpleWrappedContainer ();
|
useSimpleWrappedContainer ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,6 @@ namespace test{
|
||||||
|
|
||||||
namespace { // Subject of test
|
namespace { // Subject of test
|
||||||
|
|
||||||
|
|
||||||
uint NUM_ELMS = 10;
|
|
||||||
|
|
||||||
typedef const char* CStr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explicit implementation of the IterSource interface (test dummy)
|
* Explicit implementation of the IterSource interface (test dummy)
|
||||||
* Creates a random string and chops off a character on each iteration
|
* Creates a random string and chops off a character on each iteration
|
||||||
|
|
@ -181,11 +176,13 @@ namespace test{
|
||||||
typedef std::unordered_multimap<int,int>HashMultimap;
|
typedef std::unordered_multimap<int,int>HashMultimap;
|
||||||
|
|
||||||
|
|
||||||
|
uint NUM_ELMS{0};
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
seedRand();
|
seedRand();
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
|
NUM_ELMS = firstVal (arg, 10);
|
||||||
|
|
||||||
verify_simpleIters();
|
verify_simpleIters();
|
||||||
verify_transformIter();
|
verify_transformIter();
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,6 @@ namespace test{
|
||||||
|
|
||||||
namespace { // Test data
|
namespace { // Test data
|
||||||
|
|
||||||
uint NUM_ELMS = 10;
|
|
||||||
|
|
||||||
struct TestSource
|
struct TestSource
|
||||||
{
|
{
|
||||||
vector<int> data_;
|
vector<int> data_;
|
||||||
|
|
@ -94,11 +92,13 @@ namespace test{
|
||||||
|
|
||||||
typedef TestSource::iterator Iter;
|
typedef TestSource::iterator Iter;
|
||||||
|
|
||||||
|
uint NUM_ELMS{0};
|
||||||
|
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
|
NUM_ELMS = firstVal (arg, 10);
|
||||||
|
|
||||||
TestSource source(NUM_ELMS);
|
TestSource source(NUM_ELMS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,6 @@ namespace test {
|
||||||
|
|
||||||
namespace{ // Test data and operations
|
namespace{ // Test data and operations
|
||||||
|
|
||||||
uint NUM_ELMS = 20;
|
|
||||||
|
|
||||||
VecI
|
VecI
|
||||||
someNumberz (uint count)
|
someNumberz (uint count)
|
||||||
{
|
{
|
||||||
|
|
@ -85,14 +83,12 @@ namespace test {
|
||||||
*/
|
*/
|
||||||
class UtilCollection_test : public Test
|
class UtilCollection_test : public Test
|
||||||
{
|
{
|
||||||
|
virtual void
|
||||||
void
|
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
verify_typeDetectors();
|
verify_typeDetectors();
|
||||||
|
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
|
uint NUM_ELMS = firstVal (arg, 20);
|
||||||
|
|
||||||
VecI container = someNumberz (NUM_ELMS);
|
VecI container = someNumberz (NUM_ELMS);
|
||||||
RangeI iterator(container.begin(), container.end());
|
RangeI iterator(container.begin(), container.end());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,6 @@ namespace test {
|
||||||
|
|
||||||
namespace{ // Test data and operations
|
namespace{ // Test data and operations
|
||||||
|
|
||||||
uint NUM_ELMS = 10;
|
|
||||||
|
|
||||||
// Placeholder for argument in bind-expressions
|
// Placeholder for argument in bind-expressions
|
||||||
std::_Placeholder<1> _1;
|
std::_Placeholder<1> _1;
|
||||||
|
|
||||||
|
|
@ -122,12 +120,12 @@ namespace test {
|
||||||
*/
|
*/
|
||||||
class UtilForeach_test : public Test
|
class UtilForeach_test : public Test
|
||||||
{
|
{
|
||||||
|
uint NUM_ELMS{0};
|
||||||
|
|
||||||
void
|
virtual void
|
||||||
run (Arg arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
|
NUM_ELMS = firstVal (arg, 10);
|
||||||
|
|
||||||
VecI container = buildTestNumberz (NUM_ELMS);
|
VecI container = buildTestNumberz (NUM_ELMS);
|
||||||
RangeI iterator(container.begin(), container.end());
|
RangeI iterator(container.begin(), container.end());
|
||||||
|
|
||||||
|
|
@ -378,8 +376,8 @@ namespace test {
|
||||||
CHECK (!and_all (coll, [] (uint elm) { return 1 < elm; }));
|
CHECK (!and_all (coll, [] (uint elm) { return 1 < elm; }));
|
||||||
|
|
||||||
CHECK ( has_any (coll, [] (uint elm) { return 0 < elm; }));
|
CHECK ( has_any (coll, [] (uint elm) { return 0 < elm; }));
|
||||||
CHECK ( has_any (coll, [] (uint elm) { return elm == NUM_ELMS; }));
|
CHECK ( has_any (coll, [this](uint elm) { return elm == NUM_ELMS; }));
|
||||||
CHECK (!has_any (coll, [] (uint elm) { return elm > NUM_ELMS; }));
|
CHECK (!has_any (coll, [this](uint elm) { return elm > NUM_ELMS; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,10 +246,10 @@ function compare_template() # template plainfile
|
||||||
#tests `TESTSUITES` environment variable.
|
#tests `TESTSUITES` environment variable.
|
||||||
#tests
|
#tests
|
||||||
#tests HEAD~ Testsuites; test files; writing tests
|
#tests HEAD~ Testsuites; test files; writing tests
|
||||||
#tests It is common to start the name of the '.test' files with a 2 digi number to give them a proper
|
#tests It is common to start the name of the '.test' files with a 2 digit number to give them a proper
|
||||||
#tests order: '10foo.test', '20bar.test' and so on. Each such test should only test a certain aspect of
|
#tests order: '10foo.test', '20bar.test' and so on. Each such test should only test a certain aspect of
|
||||||
#tests the system. You have to select the testing binary with the `TESTING` function and then write
|
#tests the system. You have to select the testing binary with the `TESTING` function and then write
|
||||||
#tests certain TEST's defining how the test should react. Since tests are shell scripts it is possible
|
#tests certain TESTs defining how the test should react. Since tests are shell scripts it is possible
|
||||||
#tests to add some supplemental commands there to set and clean up the given test environment.
|
#tests to add some supplemental commands there to set and clean up the given test environment.
|
||||||
#tests
|
#tests
|
||||||
#tests HEAD^ TESTING; TESTING; set the test binary
|
#tests HEAD^ TESTING; TESTING; set the test binary
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,13 @@ namespace test {
|
||||||
{
|
{
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
run (Arg)
|
run (Arg arg)
|
||||||
{
|
{
|
||||||
seedRand();
|
seedRand();
|
||||||
smokeTest();
|
smokeTest();
|
||||||
|
if ("quick" == firstTok (arg))
|
||||||
|
return;
|
||||||
|
|
||||||
setup_systematicSchedule();
|
setup_systematicSchedule();
|
||||||
verify_instrumentation();
|
verify_instrumentation();
|
||||||
search_breaking_point();
|
search_breaking_point();
|
||||||
|
|
@ -83,7 +86,7 @@ namespace test {
|
||||||
smokeTest()
|
smokeTest()
|
||||||
{
|
{
|
||||||
MARK_TEST_FUN
|
MARK_TEST_FUN
|
||||||
TestChainLoad testLoad{512};
|
TestChainLoad testLoad{1024};
|
||||||
testLoad.configureShape_chain_loadBursts()
|
testLoad.configureShape_chain_loadBursts()
|
||||||
.buildTopology()
|
.buildTopology()
|
||||||
// .printTopologyDOT()
|
// .printTopologyDOT()
|
||||||
|
|
@ -120,8 +123,8 @@ namespace test {
|
||||||
double performanceTime =
|
double performanceTime =
|
||||||
testLoad.setupSchedule(scheduler)
|
testLoad.setupSchedule(scheduler)
|
||||||
.withLoadTimeBase(LOAD_BASE)
|
.withLoadTimeBase(LOAD_BASE)
|
||||||
.withJobDeadline(150ms)
|
.withJobDeadline (150ms) // ◁─────────────── rather tight (and below overall run time)
|
||||||
.withPlanningStep(200us)
|
.withPlanningStep(300us)
|
||||||
.withChunkSize(20)
|
.withChunkSize(20)
|
||||||
.launch_and_wait();
|
.launch_and_wait();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue