From cda1cdd975c8f09228b2a969bc825d7bb1a77564 Mon Sep 17 00:00:00 2001
From: Ichthyostega
Date: Tue, 29 Aug 2023 18:46:37 +0200
Subject: [PATCH] Activity-Lang: verify memory allocation and connectivity
---
src/vault/gear/activity-term.hpp | 4 +-
src/vault/gear/block-flow.hpp | 10 ++++
tests/vault/gear/block-flow-test.cpp | 5 ++
tests/vault/gear/scheduler-activity-test.cpp | 41 ++++++++++++----
wiki/thinkPad.ichthyo.mm | 49 +++++++++++++-------
5 files changed, 81 insertions(+), 28 deletions(-)
diff --git a/src/vault/gear/activity-term.hpp b/src/vault/gear/activity-term.hpp
index 812c3c7e5..af3ff9b76 100644
--- a/src/vault/gear/activity-term.hpp
+++ b/src/vault/gear/activity-term.hpp
@@ -181,8 +181,8 @@ namespace gear {
void
insertWorkBracket()
{
- auto start = alloc_.create (Activity::WORKSTART);
- auto stop = alloc_.create (Activity::WORKSTOP);
+ Activity& start = alloc_.create (Activity::WORKSTART);
+ Activity& stop = alloc_.create (Activity::WORKSTOP);
/////////////////////////////////////////////////////////////////////////////////////////////////TICKET #1283 define the "quality" parameter to distinguish observable execution times
insert (gate_? gate_: post_, &start);
diff --git a/src/vault/gear/block-flow.hpp b/src/vault/gear/block-flow.hpp
index f8b4d38c6..f061befca 100644
--- a/src/vault/gear/block-flow.hpp
+++ b/src/vault/gear/block-flow.hpp
@@ -674,6 +674,16 @@ namespace gear {
.transform([](Epoch& a){ return TimeValue{a.deadline()}; });
return util::join(deadlines, "|");
}
+
+ /** count all currently active allocated elements */
+ size_t
+ cntElm()
+ {
+ size_t cnt{0};
+ for (auto& epoch : flow_.allEpochs())
+ cnt += epoch.gate().filledSlots();
+ return cnt;
+ }
};
template
diff --git a/tests/vault/gear/block-flow-test.cpp b/tests/vault/gear/block-flow-test.cpp
index 065ebfd93..55e96d929 100644
--- a/tests/vault/gear/block-flow-test.cpp
+++ b/tests/vault/gear/block-flow-test.cpp
@@ -104,12 +104,14 @@ namespace test {
Activity& tick = bFlow.until(deadline).create();
CHECK (tick.verb_ == Activity::TICK);
+ CHECK (1 == watch(bFlow).cntElm());
CHECK (1 == watch(bFlow).cntEpochs());
CHECK (watch(bFlow).first() > deadline);
CHECK (watch(bFlow).first() - deadline == bFlow.getEpochStep());
bFlow.discardBefore (deadline + Time{0,5});
CHECK (0 == watch(bFlow).cntEpochs());
+ CHECK (0 == watch(bFlow).cntElm());
}
@@ -296,6 +298,9 @@ namespace test {
CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s|11s192ms|11s384ms|11s576ms"_expect);
CHECK (watch(bFlow).find(a7) == "11s576ms"_expect);
+ // we created 8 elements (a0...a7) and caused three epochs to overflow...
+ CHECK (watch(bFlow).cntElm() == 8 + EXTENT_SIZ-1 + EXTENT_SIZ-1 + EXTENT_SIZ-2);
+
// on clean-up, actual fill ratio is used to adjust to optimise Epoch length for better space usage
CHECK (bFlow.getEpochStep() == "≺192ms≻"_expect);
bFlow.discardBefore (Time{999,10});
diff --git a/tests/vault/gear/scheduler-activity-test.cpp b/tests/vault/gear/scheduler-activity-test.cpp
index 5dc8c3a76..114854f1d 100644
--- a/tests/vault/gear/scheduler-activity-test.cpp
+++ b/tests/vault/gear/scheduler-activity-test.cpp
@@ -359,19 +359,44 @@ namespace test {
BlockFlowAlloc bFlow;
ActivityLang activityLang{bFlow};
-
- Job job = detector.buildMockJob();
+
Time start{0,1};
Time dead{0,10};
- auto term = activityLang.buildCalculationJob (job,start,dead);
+ Activity* act{nullptr};
+ {
+ auto term = activityLang.buildCalculationJob (detector.buildMockJob(), start,dead);
+
+ act = & term.post();
+ }// NOTE: generated Activity chain remains valid after term goes out of scope
+
+ cout << watch(bFlow).allEpochs() < dead); // which terminates shortly after the given deadline
+ CHECK (watch(bFlow).find(*act) < dead+Time(500,0));
// Time window parameters have been included
- Activity& post = term.post();
- CHECK (Activity::POST == post.verb_);
- CHECK (start == post.data_.timeWindow.life);
- CHECK (dead == post.data_.timeWindow.dead);
+ CHECK (Activity::POST == act->verb_);
+ CHECK (start == act->data_.timeWindow.life);
+ CHECK (dead == act->data_.timeWindow.dead);
- cout << term<verb_ != Activity::INVOKE)
+ {
+ cout << util::showAddr(*act) << " verb="<verb_ <<" next="<next)<<" next.verb="<next->verb_<next;
+ }
+ CHECK (Activity::INVOKE == act->verb_);
+ cout << *act <
-
+
+
+
-
+
+
+
@@ -78041,8 +78045,8 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
@@ -78077,12 +78081,12 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
-
-
+
+
+
+
-
+
@@ -78094,7 +78098,7 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
+
@@ -78135,8 +78139,8 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
@@ -80139,15 +80143,15 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
-
+
@@ -80156,14 +80160,23 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+