Start planning the Advice implementation: skeleton of unit tests
This commit is contained in:
parent
1245f873e6
commit
abe8d876dd
9 changed files with 917 additions and 0 deletions
69
src/lib/advice.hpp
Normal file
69
src/lib/advice.hpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
ADVICE.hpp - generic loosely coupled interaction guided by symbolic pattern
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/** @file advice.hpp
|
||||
** Expecting Advice and giving Advice: a cross-cutting collaboration of loosely coupled participants.
|
||||
** TODO WIP-WIP
|
||||
**
|
||||
** @note as of 4/2010 this is an experimental setup and implemented just enough to work out
|
||||
** the interfaces. Ichthyo expects this collaboration service to play a central role
|
||||
** at various places within proc-layer.
|
||||
**
|
||||
** @see configrules.hpp
|
||||
** @see typed-lookup.cpp corresponding implementation
|
||||
** @see typed-id-test.cpp
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIB_ADVICE_H
|
||||
#define LIB_ADVICE_H
|
||||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
//#include "proc/asset.hpp"
|
||||
//#include "proc/asset/struct-scheme.hpp"
|
||||
//#include "lib/hash-indexed.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
#include "lib/symbol.hpp"
|
||||
|
||||
//#include <boost/operators.hpp>
|
||||
//#include <tr1/memory>
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
namespace lib { ///////TODO: how to arrange the namespaces best?
|
||||
namespace advice {
|
||||
|
||||
/**
|
||||
* TODO type comment
|
||||
*/
|
||||
template<class TY>
|
||||
class PointOfAdvice;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace lib::advice
|
||||
#endif
|
||||
37
src/lib/advice/advice.cpp
Normal file
37
src/lib/advice/advice.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
Advice - generic loosely coupled interaction guided by symbolic pattern
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
|
||||
// LUMIERA_ERROR_DEFINE (MISSING_INSTANCE, "Existing ID registration without associated instance");
|
||||
|
||||
|
||||
/* ohlolololohaha */
|
||||
|
||||
|
||||
|
||||
}} // namespace lib::advice
|
||||
|
|
@ -18,6 +18,36 @@ return: 0
|
|||
END
|
||||
|
||||
|
||||
PLANNED "Advice collaboration (basics)" AdviceBasics_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Advice constellations" AdviceSituations_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Advice variants and configurations" AdviceConfiguration_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Advice multiplicity and concurrency" AdviceMultiplicity_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Advice binding patterns" AdviceBindingPattern_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
PLANNED "Advice index implementation" AdviceIndex_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
|
||||
TEST "implicit conversion to bool" BoolCheckable_test <<END
|
||||
out: 1
|
||||
out: 2
|
||||
|
|
|
|||
127
tests/lib/advice/advice-basics-test.cpp
Normal file
127
tests/lib/advice/advice-basics-test.cpp
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
AdviceBasics(Test) - basic behaviour of the Advice collaboration
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @test proof-of-concept for the Advice collaboration.
|
||||
* Advice allows data exchange without coupling the participants tightly.
|
||||
* This test demonstrates the basic expected behaviour in a simple but
|
||||
* typical situation: two unrelated entities exchange a piece of data
|
||||
* just by referring to a symbolic topic ID.
|
||||
*
|
||||
* @todo partially unimplemented and thus commented out ////////////////////TICKET #605
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceSituations_test
|
||||
* @see AdviceMultiplicity_test
|
||||
* @see AdviceConfiguration_test
|
||||
* @see AdviceBindingPattern_test
|
||||
* @see AdviceIndex_test implementation test
|
||||
*/
|
||||
class AdviceBasics_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
simpleExchange();
|
||||
createCollaboration();
|
||||
overwriting_and_retracting();
|
||||
}
|
||||
|
||||
|
||||
/** @test the very basic usage situation: the advisor sets an information value
|
||||
* and the advised entity picks it up. */
|
||||
void
|
||||
simpleExchange()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
/** @test multiple ways how to initiate the advice collaboration */
|
||||
void
|
||||
createCollaboration()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
/** @test changing the provided advice, finally retracting it,
|
||||
* causing fallback on the default value */
|
||||
void
|
||||
overwriting_and_retracting()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceBasics_test, "unit common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
127
tests/lib/advice/advice-binding-pattern-test.cpp
Normal file
127
tests/lib/advice/advice-binding-pattern-test.cpp
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
AdviceBindingPattern(Test) - cover pattern matching used to dispatch Advice
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @test the pattern matching machinery used to find an Advice solution.
|
||||
* Each advice::Provision and advice::Request specifies a binding, used
|
||||
* to discern various pieces of advice. Whenever patterns on the two sides
|
||||
* match, an Advice channel is created, causing the advice provision to
|
||||
* get visible to the advised entity.
|
||||
*
|
||||
* This test creates various patterns and verifies matching behaves
|
||||
* as specified and documented.
|
||||
*
|
||||
* @todo partially unimplemented and thus commented out ////////////////////TICKET #605
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceBasics_test
|
||||
* @see AdviceMultiplicity_test
|
||||
* @see AdviceIndex_test implementation test
|
||||
*/
|
||||
class AdviceBindingPattern_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
verifyPatternNormalisation();
|
||||
verifyStaticMatch();
|
||||
verifyDynamicMatch();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
verifyPatternNormalisation()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
verifyStaticMatch()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
/** @test match against patterns containing variables,
|
||||
* verify the created solution arguments
|
||||
* @todo this is a future extension
|
||||
*/
|
||||
void
|
||||
verifyDynamicMatch()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceBindingPattern_test, "unit common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
132
tests/lib/advice/advice-configuration-test.cpp
Normal file
132
tests/lib/advice/advice-configuration-test.cpp
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
AdviceConfiguration(Test) - cover the various policies to configure Advice
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @test this is a collection of tests to cover the configuration options
|
||||
* available as policy arguments when establishing the collaboration.
|
||||
* - default advice values, or blocking or throwing
|
||||
* - using activation signals on both sides
|
||||
* - dispatch without locking (TODO any chance we can cover this by test??)
|
||||
* - more to come....
|
||||
*
|
||||
* @todo partially unimplemented and thus commented out ////////////////////TICKET #605
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceBasics_test
|
||||
* @see AdviceSituations_test
|
||||
*/
|
||||
class AdviceConfiguration_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
checkDefaultAdvice();
|
||||
blockOnAdvice();
|
||||
checkSignals();
|
||||
}
|
||||
|
||||
|
||||
/** @test typically, advice is a default constructible value,
|
||||
* so there is a natural fallback in case no active advice
|
||||
* provision exists. Alternatively we may specify to throw.
|
||||
*/
|
||||
void
|
||||
checkDefaultAdvice()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
/** @test when opening the advice collaboration, both sides may independently
|
||||
* install a signal (callback functor) to be invoked when the actual
|
||||
* advice solution gets established.
|
||||
*/
|
||||
void
|
||||
checkSignals()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
|
||||
|
||||
/** @test instead of allowing default advice values, both sides
|
||||
* may enter a blocking wait until an advice solution is available.
|
||||
* This is implemented as special case of using signals
|
||||
*/
|
||||
void
|
||||
blockOnAdvice()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #605
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceConfiguration_test, "unit common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
146
tests/lib/advice/advice-index-test.cpp
Normal file
146
tests/lib/advice/advice-index-test.cpp
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
AdviceIndex(Test) - cover the index datastructure used to implement Advice dispatch
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @test the Advice system uses an index datastructure to support matching
|
||||
* the bindings to get pairs of participants to connect by an individual
|
||||
* advice channel.
|
||||
*
|
||||
* This test covers the properties of this implementation datastucture.
|
||||
*
|
||||
* @todo partially unimplemented and thus commented out ////////////////////TICKET #608
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceBasics_test
|
||||
* @see AdviceBindingPattern_test
|
||||
*/
|
||||
class AdviceIndex_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
checkInit();
|
||||
addEntry();
|
||||
checkLookup();
|
||||
removeEntry();
|
||||
checkCollisionHandling();
|
||||
checkCleanup();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkInit()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addEntry()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkLookup()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
removeEntry()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkCollisionHandling()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkCleanup()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #608
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceIndex_test, "function common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
134
tests/lib/advice/advice-multiplicity-test.cpp
Normal file
134
tests/lib/advice/advice-multiplicity-test.cpp
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
AdviceMultiplicity(Test) - verify correctness when dispatching multiple Advices concurrently
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* @test stress test for the Advice system:
|
||||
* Concurrently add a multitude of advice provisions and check correct
|
||||
* matching and dispatch of all advice.
|
||||
*
|
||||
* @todo advanced topic, deferred for now (4/10) ////////////////////TICKET #610
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceBasics_test
|
||||
*/
|
||||
class AdviceMultiplicity_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
check_highLoadSimpleMatch();
|
||||
check_multipleMatch();
|
||||
check_unlockedDispatch();
|
||||
}
|
||||
|
||||
|
||||
/** @test run simple pairs of collaborators in multiple threads.
|
||||
* Intentionally, there should be just a single match per pair,
|
||||
* but the timings of provision and pickup are choosen randomly
|
||||
*/
|
||||
void
|
||||
check_highLoadSimpleMatch()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
}
|
||||
|
||||
|
||||
/** @test here, one advice might reach multiple advised entities and
|
||||
* one entity may receive multiple pieces of advice, overwriting
|
||||
* previous advice provisions. The receiving clients (advised entities)
|
||||
* are polling irregularly, but finally should each pick up the correct
|
||||
* value. To check this, advice values are generated with a specific
|
||||
* pattern, which can be check summed */
|
||||
void
|
||||
check_multipleMatch()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
}
|
||||
|
||||
|
||||
/** @test when dispatching Advice, some of the locking can be left out.
|
||||
* Obviously this means we can't be sure anymore the client will
|
||||
* see the newly dispatched piece of advice. But the main focus
|
||||
* of this test is to ensure the advice system itself is working
|
||||
* properly even without complete locking.
|
||||
* To verify the results, each thread performs a kind of "flush"
|
||||
* (actually creates a memory barrier) before picking up the
|
||||
* final value */
|
||||
void
|
||||
check_unlockedDispatch()
|
||||
{
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #610
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceMultiplicity_test, "function common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
115
tests/lib/advice/advice-situations-test.cpp
Normal file
115
tests/lib/advice/advice-situations-test.cpp
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
AdviceSituations(Test) - catalogue of standard Advice usage scenarios
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2010, Hermann Vosseler <Ichthyostega@web.de>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
* *****************************************************/
|
||||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
//#include "lib/test/test-helper.hpp"
|
||||
|
||||
#include "lib/advice.hpp"
|
||||
//#include "lib/p.hpp"
|
||||
//#include "proc/assetmanager.hpp"
|
||||
//#include "proc/asset/inventory.hpp"
|
||||
//#include "proc/mobject/session/clip.hpp"
|
||||
//#include "proc/mobject/session/track.hpp"
|
||||
//#include "lib/meta/trait-special.hpp"
|
||||
//#include "lib/util-foreach.hpp"
|
||||
//#include "lib/symbol.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
//#include <string>
|
||||
|
||||
//using lib::test::showSizeof;
|
||||
//using lib::test::randStr;
|
||||
//using util::isSameObject;
|
||||
//using util::and_all;
|
||||
//using util::for_each;
|
||||
//using util::isnil;
|
||||
//using lib::Literal;
|
||||
//using lib::Symbol;
|
||||
//using lumiera::P;
|
||||
//using std::string;
|
||||
//using std::cout;
|
||||
//using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace lib {
|
||||
namespace advice {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************************
|
||||
* @test documentation of the fundamental usage scenarios envisioned in the Advice concept.
|
||||
* This test will be augmented and completed as the Lumiera application matures.
|
||||
*
|
||||
* @todo partially unimplemented and thus commented out ////////////////////TICKET #335
|
||||
*
|
||||
* @see advice.hpp
|
||||
* @see AdviceBasics_test
|
||||
* @see AdviceConfiguration_test
|
||||
*/
|
||||
class AdviceSituations_test : public Test
|
||||
{
|
||||
|
||||
virtual void
|
||||
run (Arg)
|
||||
{
|
||||
check_ProxyRenderingAdvice();
|
||||
check_DependencyInjection();
|
||||
TODO ("more advice usage scenarios.....?");
|
||||
}
|
||||
|
||||
|
||||
/** @test usage scenario: switch a processing node into proxy mode. */
|
||||
void
|
||||
check_ProxyRenderingAdvice()
|
||||
{
|
||||
UNIMPLEMENTED ("anything regarding proxy rendering");
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
|
||||
}
|
||||
|
||||
|
||||
/** @test usage scenario: dependency injection for tests */
|
||||
void
|
||||
check_DependencyInjection()
|
||||
{
|
||||
UNIMPLEMENTED ("suitable advice to request and transfer test dependencies");
|
||||
#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
|
||||
#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #335
|
||||
}
|
||||
|
||||
// more to come.....
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Register this test class... */
|
||||
LAUNCHER (AdviceSituations_test, "function common");
|
||||
|
||||
|
||||
}}} // namespace lib::advice::test
|
||||
Loading…
Reference in a new issue