Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
scheduler-invocation-test.cpp
Go to the documentation of this file.
1/*
2 SchedulerInvocation(Test) - verify queue processing in the scheduler
3
4 Copyright (C)
5 2023, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
19#include "lib/test/run.hpp"
21#include "lib/util.hpp"
22
23using test::Test;
25
26
27namespace vault{
28namespace gear {
29namespace test {
30
31
32
33
34 /********************************************************************/
40 {
41
42 virtual void
52
53
56 void
58 {
60 Activity activity;
61 Time when{1,2,3};
62 Time dead{2,3,4};
63
64 CHECK (not sched.peekHead());
65
66 sched.instruct ({activity, when, dead});
67 sched.feedPrioritisation();
68 CHECK (sched.peekHead());
69
70 Activity* head = sched.pullHead();
71 CHECK (not sched.peekHead());
72 CHECK (isSameObject (*head, activity));
73 }
74
75
76
81 void
83 {
85 Activity one{1u,1u};
86 Activity two{2u,2u};
87 Activity wee{3u,3u};
88 Time t{5,5};
89
90 sched.instruct ({one, t});
91 sched.instruct ({two, t});
92 sched.instruct ({wee, t});
93 CHECK (not sched.peekHead());
94
95 sched.feedPrioritisation();
96 CHECK (isSameObject (*sched.pullHead(), one));
97 CHECK (isSameObject (*sched.pullHead(), two));
98 CHECK (isSameObject (*sched.pullHead(), wee));
99 CHECK (not sched.peekHead());
100 CHECK (sched.empty());
101 }
102
103
104
110 void
112 {
114 Activity a1{1u,1u};
115 Activity a2{2u,2u};
116 Activity a3{3u,3u};
117 Activity a4{4u,4u};
118
119 sched.instruct ({a2, Time{2,0}});
120 sched.instruct ({a4, Time{4,0}});
121 sched.feedPrioritisation();
122 CHECK (isSameObject (*sched.peekHead(), a2));
123
124 sched.instruct ({a3, Time{3,0}});
125 sched.instruct ({a1, Time{1,0}});
126 CHECK (isSameObject (*sched.peekHead(), a2));
127
128 sched.feedPrioritisation();
129 CHECK (isSameObject (*sched.pullHead(), a1));
130 CHECK (isSameObject (*sched.pullHead(), a2));
131 CHECK (isSameObject (*sched.pullHead(), a3));
132 CHECK (isSameObject (*sched.pullHead(), a4));
133 }
134
135
136
140 void
142 {
144 Activity a1{1u,1u};
145 Activity a2{2u,2u};
146 Activity a3{3u,3u};
147 Activity a4{4u,4u};
148
149 sched.feedPrioritisation ({a1, Time{0,5}});
150 sched.feedPrioritisation ({a2, Time{0,5}});
151 sched.feedPrioritisation ({a3, Time{0,5}});
152 sched.feedPrioritisation ({a4, Time{0,4}});
153 CHECK (isSameObject (*sched.pullHead(), a4));
154 CHECK (isSameObject (*sched.pullHead(), a3));
155 CHECK (isSameObject (*sched.pullHead(), a1));
156 CHECK (isSameObject (*sched.pullHead(), a2));
157 CHECK (not sched.pullHead());
158 }
159
160
161
165 void
167 {
169 Activity a1{1u,1u};
170
171 sched.feedPrioritisation ({a1, Time{0,5}});
172 CHECK (isSameObject (*sched.peekHead(), a1));
173 CHECK ( sched.isDue (Time{0,10}));
174 CHECK ( sched.isDue (Time{0,5}));
175 CHECK (not sched.isDue (Time{0,1}));
176
177 sched.pullHead();
178 CHECK (not sched.peekHead());
179 CHECK (not sched.isDue (Time{0,1}));
180 CHECK (not sched.isDue (Time{0,10}));
181 }
182
183
184
195 void
197 {
199 Activity act;
200
201 sched.feedPrioritisation ({act, Time{2,0}, Time{3,0}});
202 CHECK (Time(2,0) == sched.headTime());
203 CHECK ( sched.isDue (Time{2,0}));
204 CHECK (not sched.isMissed (Time{2,0}));
205 CHECK (not sched.isMissed (Time{3,0}));
206 CHECK ( sched.isMissed (Time{4,0}));
207
208 CHECK (not sched.isOutdated (Time{2,0}));
209 CHECK (not sched.isOutdated (Time{3,0}));
210 CHECK ( sched.isOutdated (Time{4,0}));
211
212 sched.feedPrioritisation ({act, Time{1,0}, Time{3,0}, ManifestationID{5}});
213 CHECK (Time(1,0) == sched.headTime());
214 CHECK ( sched.isOutdated (Time{1,0}));
215 CHECK (not sched.isMissed (Time{1,0}));
216
217 sched.activate (ManifestationID{5});
218 CHECK (Time(1,0) == sched.headTime());
219 CHECK ( sched.isDue (Time{1,0}));
220 CHECK (not sched.isOutdated (Time{1,0}));
221 CHECK (not sched.isOutdated (Time{3,0}));
222 CHECK ( sched.isOutdated (Time{4,0}));
223 CHECK ( sched.isMissed (Time{4,0}));
224 CHECK ( sched.isDue (Time{4,0}));
225
226 sched.activate (ManifestationID{23});
227 CHECK (not sched.isOutdated (Time{1,0}));
228
229 sched.drop (ManifestationID{5});
230 CHECK (Time(1,0) == sched.headTime());
231 CHECK ( sched.isOutdated (Time{1,0}));
232 CHECK ( sched.isOutdated (Time{4,0}));
233 CHECK ( sched.isMissed (Time{4,0}));
234 CHECK (not sched.isMissed (Time{1,0}));
235 CHECK ( sched.isDue (Time{1,0}));
236
237 sched.feedPrioritisation ({act, Time{0,0}, Time{2,0}, ManifestationID{23}, true});
238 CHECK (Time(0,0) == sched.headTime()); // ^^^^ marked as compulsory
239 CHECK (not sched.isMissed (Time{1,0}));
240 CHECK (not sched.isOutdated (Time{1,0}));
241 CHECK (not sched.isOutOfTime(Time{2,0})); // still OK /at/ deadline
242 CHECK ( sched.isOutOfTime(Time{3,0})); // ↯ past deadline yet marked as compulsory
243 CHECK ( sched.isOutdated (Time{3,0}));
244 CHECK ( sched.isMissed (Time{3,0}));
245
246 sched.drop (ManifestationID{5});
247 CHECK ( sched.isOutOfTime(Time{3,0})); // Manifestation-5 is altogether irrelevant for this case
248
249 sched.drop (ManifestationID{23});
250 CHECK (Time(0,0) == sched.headTime());
251 CHECK ( sched.isOutdated (Time{1,0}));
252 CHECK (not sched.isOutOfTime(Time{2,0}));
253 CHECK (not sched.isOutOfTime(Time{3,0})); // the disabled manifestation-23 masks the fatal out-of-time state
254 CHECK ( sched.isOutdated (Time{3,0}));
255 CHECK ( sched.isMissed (Time{3,0}));
256
257 sched.pullHead();
258 CHECK (Time(1,0) == sched.headTime());
259 CHECK ( sched.isOutdated (Time{1,0}));
260 CHECK ( sched.isDue (Time{1,0}));
261
262 sched.pullHead();
263 CHECK (Time(2,0) == sched.headTime());
264 CHECK (not sched.isOutdated (Time{2,0}));
265 CHECK ( sched.isOutdated (Time{4,0}));
266 CHECK ( sched.isMissed (Time{4,0}));
267 CHECK ( sched.isDue (Time{4,0}));
268
269 sched.pullHead();
270 CHECK (Time::NEVER == sched.headTime());
271 CHECK (not sched.isMissed (Time{4,0}));
272 CHECK (not sched.isOutdated (Time{4,0}));
273 CHECK (not sched.isDue (Time{4,0}));
274 CHECK (sched.empty());
275 }
276 };
277
278
281
282
283
284}}} // namespace vault::gear::test
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
Abstract Base Class for all testcases.
Definition run.hpp:54
Record to describe an Activity, to happen within the Scheduler's control flow.
Definition activity.hpp:227
Marker for current (and obsolete) manifestations of a CalcStream processed by the Render-Engine.
Definition activity.hpp:85
Scheduler Layer-1 : time based dispatch.
void instruct(ActivationEvent actEvent)
Accept an ActivationEvent with an Activity for time-bound execution.
bool isDue(Time now) const
Determine if there is work to do right now.
bool isOutOfTime(Time now) const
detect a compulsory Activity at scheduler head with missed deadline
bool isMissed(Time now) const
determine if the Activity at scheduler head missed it's deadline.
bool isOutdated(Time now) const
determine if Activity at scheduler is outdated and should be discarded
void activate(ManifestationID manID)
Enable entries marked with a specific ManifestationID to be processed.
void feedPrioritisation()
Pick up all new events from the entrance queue and enqueue them to be retrieved ordered by start time...
ActivationEvent pullHead()
Retrieve from the scheduling queue the entry with earliest start time.
Test runner and basic definitions for tests.
bool isSameObject(A const &a, B const &b)
compare plain object identity, based directly on the referee's memory identities.
Definition util.hpp:421
Vault-Layer implementation namespace root.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
Layer-1 of the Scheduler: queueing and prioritisation of activities.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...