Activity-Lang: draft invocation verification
This commit is contained in:
parent
111c05a1f9
commit
6e42e81546
4 changed files with 180 additions and 6 deletions
|
|
@ -215,5 +215,14 @@ namespace util {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** shortcut: List in parentheses, separated by comma, using temporary vector */
|
||||||
|
template<typename...ARGS>
|
||||||
|
inline string
|
||||||
|
joinArgList (ARGS const& ...args)
|
||||||
|
{
|
||||||
|
return "("+join (stringify<std::vector<string>> (args...))+")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
#endif /*LIB_FORMAT_UTIL_H*/
|
#endif /*LIB_FORMAT_UTIL_H*/
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ namespace test {
|
||||||
{
|
{
|
||||||
simpleUsage();
|
simpleUsage();
|
||||||
|
|
||||||
verifyDummyFuncttor();
|
verifyMockInvocation();
|
||||||
|
verifyDummyJobFunctor();
|
||||||
detect_activation();
|
detect_activation();
|
||||||
detect_gate();
|
detect_gate();
|
||||||
}
|
}
|
||||||
|
|
@ -92,11 +93,40 @@ namespace test {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** @test verify the setup and detection of instrumented invocations
|
||||||
|
* @todo WIP 7/23 ⟶ define ⟶ implement
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
verifyMockInvocation()
|
||||||
|
{
|
||||||
|
ActivityDetector detector;
|
||||||
|
auto fun = detector.buildDiagnosticFun<void(uint)>("funny");
|
||||||
|
uint rnd = rand() % 10000;
|
||||||
|
|
||||||
|
++detector;
|
||||||
|
CHECK (1 == detector.currSeq());
|
||||||
|
CHECK (not detector.verifyInvocation ("funny"));
|
||||||
|
|
||||||
|
detector.markSequence();
|
||||||
|
fun(rnd);
|
||||||
|
detector.markSequence();
|
||||||
|
CHECK (detector.verifyInvocation ("funny"));
|
||||||
|
CHECK (detector.verifyInvocation ("funny", rnd));
|
||||||
|
CHECK (detector.verifyInvocation ("funny", Seq(1)));
|
||||||
|
CHECK (detector.verifyInvocation ("funny", Seq(1), rnd));
|
||||||
|
CHECK (not detector.verifyInvocation ("bunny"));
|
||||||
|
CHECK (not detector.verifyInvocation ("funny", -rnd));
|
||||||
|
CHECK (not detector.verifyInvocation ("funny", Seq(5)));
|
||||||
|
CHECK (not detector.verifyInvocation ("funny", rnd, Seq(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @test TODO diagnostic setup to detect a JobFunctor activation
|
/** @test TODO diagnostic setup to detect a JobFunctor activation
|
||||||
* @todo WIP 7/23 ⟶ define ⟶ implement
|
* @todo WIP 7/23 ⟶ define ⟶ implement
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
verifyDummyFuncttor()
|
verifyDummyJobFunctor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@
|
||||||
//#include "lib/linked-elements.hpp"
|
//#include "lib/linked-elements.hpp"
|
||||||
#include "lib/meta/variadic-helper.hpp"
|
#include "lib/meta/variadic-helper.hpp"
|
||||||
#include "lib/wrapper.hpp"
|
#include "lib/wrapper.hpp"
|
||||||
|
#include "lib/format-cout.hpp"
|
||||||
#include "lib/format-util.hpp"
|
#include "lib/format-util.hpp"
|
||||||
//#include "lib/itertools.hpp"
|
//#include "lib/itertools.hpp"
|
||||||
//#include "lib/depend.hpp"
|
//#include "lib/depend.hpp"
|
||||||
|
|
@ -94,6 +95,45 @@ namespace test {
|
||||||
// using vault::gear::JobClosure;
|
// using vault::gear::JobClosure;
|
||||||
|
|
||||||
|
|
||||||
|
/** Marker for invocation sequence */
|
||||||
|
class Seq
|
||||||
|
{
|
||||||
|
uint step_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Seq (uint start =0)
|
||||||
|
: step_{start}
|
||||||
|
{ }
|
||||||
|
|
||||||
|
operator uint() const
|
||||||
|
{
|
||||||
|
return step_;
|
||||||
|
}
|
||||||
|
operator string() const
|
||||||
|
{
|
||||||
|
return util::toString (step_);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
operator++()
|
||||||
|
{
|
||||||
|
++step_;
|
||||||
|
return step_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
operator== (Seq const& o)
|
||||||
|
{
|
||||||
|
return step_ == o.step_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
namespace {// Event markers
|
||||||
|
const string MARK_INC{"Inc"};
|
||||||
|
const string MARK_SEQ{"Seq"};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Diagnostic context to record and evaluate activations within the Scheduler.
|
* Diagnostic context to record and evaluate activations within the Scheduler.
|
||||||
|
|
@ -105,6 +145,7 @@ namespace test {
|
||||||
using EventLog = lib::test::EventLog;
|
using EventLog = lib::test::EventLog;
|
||||||
|
|
||||||
EventLog eventLog_;
|
EventLog eventLog_;
|
||||||
|
Seq invocationSeq_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Mock functor, logging all invocations into the EventLog
|
* A Mock functor, logging all invocations into the EventLog
|
||||||
|
|
@ -126,10 +167,11 @@ namespace test {
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** prepare a response value to return from the mock invocation */
|
/** prepare a response value to return from the mock invocation */
|
||||||
|
template<typename VAL>
|
||||||
DiagnosticFun&&
|
DiagnosticFun&&
|
||||||
returning (RET&& riggedResponse)
|
returning (VAL&& riggedResponse)
|
||||||
{
|
{
|
||||||
retVal_ = std::forward<RET> (riggedResponse);
|
retVal_ = std::forward<VAL> (riggedResponse);
|
||||||
return std::move (*this);
|
return std::move (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,8 +186,9 @@ namespace test {
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActivityDetector(string id)
|
ActivityDetector(string id ="")
|
||||||
: eventLog_{"ActivityDetector" + (isnil (id)? string{}: "("+id+")")}
|
: eventLog_{"ActivityDetector" + (isnil (id)? string{}: "("+id+")")}
|
||||||
|
, invocationSeq_{0}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
operator string() const
|
operator string() const
|
||||||
|
|
@ -162,6 +205,28 @@ namespace test {
|
||||||
eventLog_.clear (newID);
|
eventLog_.clear (newID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
operator++()
|
||||||
|
{
|
||||||
|
++invocationSeq_;
|
||||||
|
eventLog_.event (MARK_INC, invocationSeq_);
|
||||||
|
return invocationSeq_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
currSeq() const
|
||||||
|
{
|
||||||
|
return invocationSeq_;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
markSequence()
|
||||||
|
{
|
||||||
|
eventLog_.event (MARK_SEQ, invocationSeq_);
|
||||||
|
return operator++();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic testing helper: build a λ-mock, logging all invocations
|
* Generic testing helper: build a λ-mock, logging all invocations
|
||||||
* @tparam SIG signature of the functor to be generated
|
* @tparam SIG signature of the functor to be generated
|
||||||
|
|
@ -181,6 +246,36 @@ namespace test {
|
||||||
return Functor{id, eventLog_};
|
return Functor{id, eventLog_};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename...ARGS>
|
||||||
|
bool
|
||||||
|
verifyInvocation (string fun, Seq const& seq, ARGS const& ...args)
|
||||||
|
{
|
||||||
|
bool valid = eventLog_.verifyEvent(seq).id(MARK_INC)
|
||||||
|
.beforeCall(fun).arg(args...)
|
||||||
|
.beforeEvent(seq).id(MARK_SEQ);
|
||||||
|
if (not valid)
|
||||||
|
{
|
||||||
|
cerr << "FAIL___Function_invocation___________"
|
||||||
|
<< "\nfunction:"<<fun<<util::joinArgList (args...)
|
||||||
|
<< "\nsequence:"<<seq
|
||||||
|
<< "\n_______Event-Log_____________________\n"
|
||||||
|
<< util::join(eventLog_, "\n")
|
||||||
|
<< "\n───────╼━━━━━━━━╾────────────────────"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename...ARGS>
|
||||||
|
bool
|
||||||
|
verifyInvocation (string fun, ARGS const& ...args)
|
||||||
|
{
|
||||||
|
Seq currentEventSeq = invocationSeq_;
|
||||||
|
markSequence(); // NOTE: incrementing here
|
||||||
|
return verifyInvocation (fun, currentEventSeq, args...);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81700,7 +81700,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690891585410" ID="ID_1976653650" MODIFIED="1690891593537" TEXT="Action-Hook">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690891585410" ID="ID_1976653650" MODIFIED="1690891593537" TEXT="Action-Hook">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690891602401" ID="ID_1359624247" MODIFIED="1690896708168" TEXT="als Primitive einführen">
|
<node COLOR="#435e98" CREATED="1690891602401" ID="ID_1359624247" MODIFIED="1690899606451" TEXT="als Primitive einführen">
|
||||||
<richcontent TYPE="NOTE"><html>
|
<richcontent TYPE="NOTE"><html>
|
||||||
<head/>
|
<head/>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -81713,9 +81713,49 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
||||||
<linktarget COLOR="#759db4" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="446;-43;" ID="Arrow_ID_265182299" SOURCE="ID_642006957" STARTARROW="None" STARTINCLINATION="1008;65;"/>
|
<linktarget COLOR="#759db4" DESTINATION="ID_1359624247" ENDARROW="Default" ENDINCLINATION="446;-43;" ID="Arrow_ID_265182299" SOURCE="ID_642006957" STARTARROW="None" STARTINCLINATION="1008;65;"/>
|
||||||
<icon BUILTIN="yes"/>
|
<icon BUILTIN="yes"/>
|
||||||
</node>
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1690899608350" ID="ID_1677406479" MODIFIED="1690899761758" TEXT="muß Downcast auf konkreten Execution-context machen">
|
||||||
|
<richcontent TYPE="NOTE"><html>
|
||||||
|
<head/>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
geht leider nicht anders, weil ich mich für eine generische (concept-artige) Form des Execution-context entschieden habe; eine virtuelle Methode kann selber kein Template sein, und andererseits möchte ich den Activity-Record selber template-frei halten
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html></richcontent>
|
||||||
|
<icon BUILTIN="messagebox_warning"/>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205029658" ID="ID_1144318045" MODIFIED="1689205033146" TEXT="Verifikationen">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205029658" ID="ID_1144318045" MODIFIED="1689205033146" TEXT="Verifikationen">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1690899802680" ID="ID_383665548" MODIFIED="1690899840591" TEXT="Problem: zweifelsfreie Verifikation im Log">
|
||||||
|
<icon BUILTIN="messagebox_warning"/>
|
||||||
|
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1690899845778" ID="ID_527585169" MODIFIED="1690899886750" TEXT="muß fehl-Matches vermeiden">
|
||||||
|
<icon BUILTIN="clanbomber"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690899868436" ID="ID_1034519064" MODIFIED="1690899890797" TEXT="Log sollte idealerweise komplett verifizierbar sein">
|
||||||
|
<icon BUILTIN="yes"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690899789651" ID="ID_495093897" MODIFIED="1690899844507" TEXT="eine Sequenz-Nummer einführen">
|
||||||
|
<icon BUILTIN="idea"/>
|
||||||
|
<node CREATED="1690899895228" ID="ID_689471700" MODIFIED="1690899900231" TEXT="an die Instanz gebunden"/>
|
||||||
|
<node CREATED="1690899900699" ID="ID_1842080361" MODIFIED="1690899905547" TEXT="damit 100% reproduzierbar"/>
|
||||||
|
<node CREATED="1690899906154" ID="ID_350339048" MODIFIED="1690899917269" TEXT="impliziert eine Aufruf-Sequenz"/>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690900159528" ID="ID_689193567" MODIFIED="1690900179719" TEXT="Wrapper-Typ verwenden (keinen primitiven Typ)">
|
||||||
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690899920322" ID="ID_67461983" MODIFIED="1690899953072" TEXT="den Einzel-Aufruf mit der Nummer einklammern">
|
||||||
|
<icon BUILTIN="idea"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
|
<node CREATED="1690899978840" ID="ID_70827658" MODIFIED="1690899987515" TEXT="einen Funktionsaufruf verifizieren">
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690900023906" ID="ID_1470650457" MODIFIED="1690918796008" TEXT="markSequence()">
|
||||||
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1690900069493" ID="ID_917256156" MODIFIED="1690900150148" TEXT="verifyInvocation(fun, Seq(i), args...)">
|
||||||
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205081622" ID="ID_1440811513" MODIFIED="1689205086027" TEXT="Meßpunkte">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1689205081622" ID="ID_1440811513" MODIFIED="1689205086027" TEXT="Meßpunkte">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue