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:
Fischlurch 2024-11-15 19:02:48 +01:00
parent bf41474004
commit 39d614f55f
15 changed files with 73 additions and 67 deletions

View file

@ -22,13 +22,14 @@
*/
/** @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
** by defining a Launcher instance, which can be done conveniently by the macro LAUNCHER
**
** @see HelloWorld_test
** @see test::Suite
** @see testrunner.cpp
** @see random.hpp
** @see main.cpp
*/
@ -51,7 +52,7 @@ namespace test {
using std::string;
using std::shared_ptr;
typedef std::vector<string> & Arg;
using Arg = std::vector<string> &;
@ -62,11 +63,13 @@ namespace test {
class Test
{
public:
virtual ~Test() = default;
virtual ~Test() = default; ///< this is an interface
virtual void run(Arg arg) = 0;
void seedRand();
lib::Random makeRandGen();
void seedRand(); ///< draw a new random seed from a common nucleus, and re-seed the default-Gen.
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
// make them global for convenience
// make those global for convenience....
using ::test::Arg;
using ::test::Test;
using ::test::Launch;
@ -121,8 +124,8 @@ using lib::defaultGen;
// and provide shortcut for registration
#define LAUNCHER(_TEST_CLASS_, _GROUPS_) \
/** Register _TEST_CLASS_ to be invoked in some test suites (groups) _GROUPS_ */ \
/** Register _TEST_CLASS_ to be invoked in some test suites (groups) _GROUPS_ */ \
Launch<_TEST_CLASS_> run_##_TEST_CLASS_##_(STRINGIFY(_TEST_CLASS_), _GROUPS_);
#endif
#endif /*TESTHELPER_RUN_H*/

View file

@ -215,7 +215,7 @@ namespace test {
}
/** draw a new random seed from a common nucleus, and re-seed the default-Gen. */
void
Test::seedRand()
{
@ -223,7 +223,6 @@ namespace test {
}
/** build a dedicated new RandomGen, seeded from the default-Gen */
Random
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.
* The first argument in the commandline, if present,

View file

@ -56,7 +56,7 @@ END
TEST "Scheduler Performance" SchedulerStress_test <<END
TEST "Scheduler Performance" SchedulerStress_test quick <<END
return: 0
END

View file

@ -101,8 +101,7 @@ namespace test{
virtual void
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;
Interface::setCountParam(num);

View file

@ -83,7 +83,7 @@ namespace test{
virtual void
run (Arg arg)
{
uint num= isnil(arg)? 1 : lexical_cast<uint>(arg[1]);
uint num{firstVal (arg)};
Depend<TargetObj> singleton;

View file

@ -49,7 +49,8 @@ namespace 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");
}

View file

@ -49,8 +49,7 @@ namespace test {
virtual void
run (Arg arg)
{
int num= isnil(arg)? 1 : lexical_cast<int> (arg[1]);
uint num{firstVal (arg)};
for ( ; 0 < num-- ; )
greeting();
}

View file

@ -60,11 +60,6 @@ namespace test{
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
{
uint NUM_ELMS{0};
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
NUM_ELMS = firstVal (arg, 10);
checkDistinctValIter();

View file

@ -52,11 +52,9 @@ namespace test{
namespace {
uint NUM_ELMS = 10;
/** example of simply wrapping an STL container
* and exposing a range as Lumiera Forward Iterator
/**
* example of simply wrapping an STL container
* and exposing a range as Lumiera Forward Iterator
*/
struct WrappedVector
{
@ -192,11 +190,12 @@ namespace test{
*/
class IterAdapter_test : public Test
{
uint NUM_ELMS{0};
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
NUM_ELMS = firstVal (arg, 10);
useSimpleWrappedContainer ();

View file

@ -69,11 +69,6 @@ namespace test{
namespace { // Subject of test
uint NUM_ELMS = 10;
typedef const char* CStr;
/**
* Explicit implementation of the IterSource interface (test dummy)
* 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;
uint NUM_ELMS{0};
virtual void
run (Arg arg)
{
seedRand();
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
NUM_ELMS = firstVal (arg, 10);
verify_simpleIters();
verify_transformIter();

View file

@ -54,8 +54,6 @@ namespace test{
namespace { // Test data
uint NUM_ELMS = 10;
struct TestSource
{
vector<int> data_;
@ -94,11 +92,13 @@ namespace test{
typedef TestSource::iterator Iter;
uint NUM_ELMS{0};
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
NUM_ELMS = firstVal (arg, 10);
TestSource source(NUM_ELMS);

View file

@ -59,8 +59,6 @@ namespace test {
namespace{ // Test data and operations
uint NUM_ELMS = 20;
VecI
someNumberz (uint count)
{
@ -85,14 +83,12 @@ namespace test {
*/
class UtilCollection_test : public Test
{
void
virtual void
run (Arg arg)
{
verify_typeDetectors();
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[0]);
uint NUM_ELMS = firstVal (arg, 20);
VecI container = someNumberz (NUM_ELMS);
RangeI iterator(container.begin(), container.end());

View file

@ -59,8 +59,6 @@ namespace test {
namespace{ // Test data and operations
uint NUM_ELMS = 10;
// Placeholder for argument in bind-expressions
std::_Placeholder<1> _1;
@ -122,12 +120,12 @@ namespace test {
*/
class UtilForeach_test : public Test
{
uint NUM_ELMS{0};
void
virtual void
run (Arg arg)
{
if (0 < arg.size()) NUM_ELMS = lexical_cast<uint> (arg[1]);
NUM_ELMS = firstVal (arg, 10);
VecI container = buildTestNumberz (NUM_ELMS);
RangeI iterator(container.begin(), container.end());
@ -377,9 +375,9 @@ namespace test {
CHECK ( and_all (coll, [] (uint elm) { return 0 < 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 elm == NUM_ELMS; }));
CHECK (!has_any (coll, [] (uint elm) { return elm > NUM_ELMS; }));
CHECK ( has_any (coll, [] (uint elm) { return 0 < elm; }));
CHECK ( has_any (coll, [this](uint elm) { return elm == NUM_ELMS; }));
CHECK (!has_any (coll, [this](uint elm) { return elm > NUM_ELMS; }));
}

View file

@ -246,10 +246,10 @@ function compare_template() # template plainfile
#tests `TESTSUITES` environment variable.
#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 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
#tests HEAD^ TESTING; TESTING; set the test binary

View file

@ -65,10 +65,13 @@ namespace test {
{
virtual void
run (Arg)
run (Arg arg)
{
seedRand();
smokeTest();
if ("quick" == firstTok (arg))
return;
setup_systematicSchedule();
verify_instrumentation();
search_breaking_point();
@ -83,7 +86,7 @@ namespace test {
smokeTest()
{
MARK_TEST_FUN
TestChainLoad testLoad{512};
TestChainLoad testLoad{1024};
testLoad.configureShape_chain_loadBursts()
.buildTopology()
// .printTopologyDOT()
@ -120,8 +123,8 @@ namespace test {
double performanceTime =
testLoad.setupSchedule(scheduler)
.withLoadTimeBase(LOAD_BASE)
.withJobDeadline(150ms)
.withPlanningStep(200us)
.withJobDeadline (150ms) // ◁─────────────── rather tight (and below overall run time)
.withPlanningStep(300us)
.withChunkSize(20)
.launch_and_wait();