Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f18d696fcaa9a3a0bf41e255fe5dc9f6674c229f
[simgrid.git] / src / mc / explo / odpor / Execution_test.cpp
1 /* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved.               */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "src/3rd-party/catch.hpp"
7 #include "src/mc/explo/odpor/Execution.hpp"
8 #include "src/mc/explo/udpor/udpor_tests_private.hpp"
9 #include "src/mc/transition/TransitionComm.hpp"
10
11 using namespace simgrid::mc;
12 using namespace simgrid::mc::odpor;
13 using namespace simgrid::mc::udpor;
14
15 TEST_CASE("simgrid::mc::odpor::Execution: Constructing Executions")
16 {
17   Execution execution;
18   REQUIRE(execution.empty());
19   REQUIRE(execution.size() == 0);
20   REQUIRE_FALSE(execution.get_latest_event_handle().has_value());
21 }
22
23 TEST_CASE("simgrid::mc::odpor::Execution: Testing Happens-Before")
24 {
25   SECTION("Example 1")
26   {
27     // We check each permutation for happens before
28     // among the given actions added to the execution
29     const auto a1 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
30     const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
31     const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
32     const auto a4 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 4);
33
34     Execution execution;
35     execution.push_transition(a1);
36     execution.push_transition(a2);
37     execution.push_transition(a3);
38     execution.push_transition(a4);
39
40     SECTION("Happens-before is irreflexive")
41     {
42       REQUIRE_FALSE(execution.happens_before(0, 0));
43       REQUIRE_FALSE(execution.happens_before(1, 1));
44       REQUIRE_FALSE(execution.happens_before(2, 2));
45       REQUIRE_FALSE(execution.happens_before(3, 3));
46     }
47
48     SECTION("Happens-before values for each pair of events")
49     {
50       REQUIRE_FALSE(execution.happens_before(0, 1));
51       REQUIRE_FALSE(execution.happens_before(0, 2));
52       REQUIRE(execution.happens_before(0, 3));
53       REQUIRE_FALSE(execution.happens_before(1, 2));
54       REQUIRE_FALSE(execution.happens_before(1, 3));
55       REQUIRE_FALSE(execution.happens_before(2, 3));
56     }
57
58     SECTION("Happens-before is a subset of 'occurs-before' ")
59     {
60       REQUIRE_FALSE(execution.happens_before(1, 0));
61       REQUIRE_FALSE(execution.happens_before(2, 0));
62       REQUIRE_FALSE(execution.happens_before(3, 0));
63       REQUIRE_FALSE(execution.happens_before(2, 1));
64       REQUIRE_FALSE(execution.happens_before(3, 1));
65       REQUIRE_FALSE(execution.happens_before(3, 2));
66     }
67   }
68
69   SECTION("Example 2")
70   {
71     const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
72     const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
73     const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
74     const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
75
76     // Notice that `a5` and `a6` are executed by the same actor; thus, although
77     // the actor is executing independent actions, each still "happen-before"
78     // the another
79
80     Execution execution;
81     execution.push_transition(a1);
82     execution.push_transition(a2);
83     execution.push_transition(a3);
84     execution.push_transition(a4);
85
86     SECTION("Happens-before is irreflexive")
87     {
88       REQUIRE_FALSE(execution.happens_before(0, 0));
89       REQUIRE_FALSE(execution.happens_before(1, 1));
90       REQUIRE_FALSE(execution.happens_before(2, 2));
91       REQUIRE_FALSE(execution.happens_before(3, 3));
92     }
93
94     SECTION("Happens-before values for each pair of events")
95     {
96       REQUIRE_FALSE(execution.happens_before(0, 1));
97       REQUIRE_FALSE(execution.happens_before(0, 2));
98       REQUIRE_FALSE(execution.happens_before(0, 3));
99       REQUIRE(execution.happens_before(1, 2));
100       REQUIRE(execution.happens_before(1, 3));
101       REQUIRE(execution.happens_before(2, 3));
102     }
103
104     SECTION("Happens-before is a subset of 'occurs-before'")
105     {
106       REQUIRE_FALSE(execution.happens_before(1, 0));
107       REQUIRE_FALSE(execution.happens_before(2, 0));
108       REQUIRE_FALSE(execution.happens_before(3, 0));
109       REQUIRE_FALSE(execution.happens_before(2, 1));
110       REQUIRE_FALSE(execution.happens_before(3, 1));
111       REQUIRE_FALSE(execution.happens_before(3, 2));
112     }
113   }
114 }
115
116 TEST_CASE("simgrid::mc::odpor::Execution: Testing Racing Events and Initials")
117 {
118   SECTION("Example 1")
119   {
120     const auto a1 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
121     const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
122     const auto a3 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
123     const auto a4 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
124     const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
125
126     Execution execution;
127     execution.push_transition(a1);
128     execution.push_transition(a2);
129     execution.push_transition(a3);
130     execution.push_transition(a4);
131     execution.push_transition(a5);
132
133     // Nothing comes before event 0
134     REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
135
136     // Events 0 and 1 are independent
137     REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
138
139     // 2 and 1 are executed by different actors and happen right after each other
140     REQUIRE(execution.get_racing_events_of(2) == std::unordered_set<Execution::EventHandle>{1});
141
142     // Although a3 and a4 are dependent, they are executed by the same actor
143     REQUIRE(execution.get_racing_events_of(3) == std::unordered_set<Execution::EventHandle>{});
144
145     // Event 4 is in a race with neither event 0 nor event 2 since those events
146     // "happen-before" event 3 with which event 4 races
147     //
148     // Furthermore, event 1 is run by the same actor and thus also is not in a race.
149     // Hence, only event 3 races with event 4
150     REQUIRE(execution.get_racing_events_of(4) == std::unordered_set<Execution::EventHandle>{3});
151   }
152
153   SECTION("Example 2: Events with multiple races")
154   {
155     const auto a1 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
156     const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
157     const auto a3 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
158     const auto a4 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
159
160     Execution execution;
161     execution.push_transition(a1);
162     execution.push_transition(a2);
163     execution.push_transition(a3);
164     execution.push_transition(a4);
165
166     // Nothing comes before event 0
167     REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
168
169     // Events 0 and 1 are independent
170     REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
171
172     // Event 2 is independent with event 1 and run by the same actor as event 0
173     REQUIRE(execution.get_racing_events_of(2) == std::unordered_set<Execution::EventHandle>{});
174
175     // All events are dependent with event 3, but event 0 "happens-before" event 2
176     REQUIRE(execution.get_racing_events_of(3) == std::unordered_set<Execution::EventHandle>{1, 2});
177
178     SECTION("Check initials with respect to event 1")
179     {
180       // First, note that v := notdep(1, execution).p == {e2}.{e3} == {e2, e3}
181       // Since e2 -->_E e3, actor 3 is not an initial for E' := pre(1, execution)
182       // with respect to `v`. e2, however, has nothing happening before it in dom_E(v),
183       // so it is an initial of E' wrt. `v`
184       const auto initial_wrt_event1 = execution.get_missing_source_set_actors_from(1, std::unordered_set<aid_t>{});
185       REQUIRE(initial_wrt_event1 == std::unordered_set<aid_t>{1});
186     }
187
188     SECTION("Check initials with respect to event 2")
189     {
190       // First, note that v := notdep(1, execution).p == {}.{e3} == {e3}
191       // e3 has nothing happening before it in dom_E(v), so it is an initial
192       // of E' wrt. `v`
193       const auto initial_wrt_event2 = execution.get_missing_source_set_actors_from(2, std::unordered_set<aid_t>{});
194       REQUIRE(initial_wrt_event2 == std::unordered_set<aid_t>{3});
195     }
196   }
197
198   SECTION("Example 3: Testing 'Lock' Example")
199   {
200     // In this example,
201     const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
202     const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
203     const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
204     const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
205     const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
206
207     Execution execution;
208     execution.push_transition(a1);
209     execution.push_transition(a2);
210     execution.push_transition(a3);
211     execution.push_transition(a4);
212     execution.push_transition(a5);
213
214     REQUIRE(execution.get_racing_events_of(4) == std::unordered_set<Execution::EventHandle>{0});
215   }
216
217   SECTION("Example 4: Indirect Races")
218   {
219     const auto a0 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
220     const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
221     const auto a2 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
222     const auto a3 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
223     const auto a4 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 6);
224     const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
225     const auto a6 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
226     const auto a7 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
227     const auto a8 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
228     const auto a9 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
229
230     Execution execution;
231     execution.push_transition(a0);
232     execution.push_transition(a1);
233     execution.push_transition(a2);
234     execution.push_transition(a3);
235     execution.push_transition(a4);
236     execution.push_transition(a5);
237     execution.push_transition(a6);
238     execution.push_transition(a7);
239     execution.push_transition(a8);
240     execution.push_transition(a9);
241
242     // Nothing comes before event 0
243     REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
244
245     // Events 0 and 1 are independent
246     REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
247
248     // Events 1 and 2 are independent
249     REQUIRE(execution.get_racing_events_of(2) == std::unordered_set<Execution::EventHandle>{});
250
251     // Events 1 and 3 are independent; the rest are executed by the same actor
252     REQUIRE(execution.get_racing_events_of(3) == std::unordered_set<Execution::EventHandle>{});
253
254     // 1. Events 3 and 4 race
255     // 2. Events 2 and 4 do NOT race since 2 --> 3 --> 4
256     // 3. Events 1 and 4 do NOT race since 1 is independent of 4
257     // 4. Events 0 and 4 do NOT race since 0 --> 2 --> 4
258     REQUIRE(execution.get_racing_events_of(4) == std::unordered_set<Execution::EventHandle>{3});
259
260     // Events 4 and 5 race; and because everyone before 4 (including 3) either
261     // a) happens-before, b) races, or c) does not race with 4, 4 is the race
262     REQUIRE(execution.get_racing_events_of(5) == std::unordered_set<Execution::EventHandle>{4});
263
264     // The same logic that applied to event 5 applies to event 6
265     REQUIRE(execution.get_racing_events_of(6) == std::unordered_set<Execution::EventHandle>{5});
266
267     // The same logic applies, except that this time since events 6 and 7 are run
268     // by the same actor, they don'tt actually race with one another
269     REQUIRE(execution.get_racing_events_of(7) == std::unordered_set<Execution::EventHandle>{});
270
271     // Event 8 is independent with everything
272     REQUIRE(execution.get_racing_events_of(8) == std::unordered_set<Execution::EventHandle>{});
273
274     // Event 9 is independent with events 7 and 8; event 6, however, is in race with 9.
275     // The same logic above eliminates events before 6
276     REQUIRE(execution.get_racing_events_of(9) == std::unordered_set<Execution::EventHandle>{6});
277   }
278 }
279
280 TEST_CASE("simgrid::mc::odpor::Execution: Testing Races and Conditions")
281 {
282   const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
283   const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
284   const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
285   const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
286   const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
287
288   Execution execution;
289   execution.push_transition(a1);
290   execution.push_transition(a2);
291   execution.push_transition(a3);
292   execution.push_transition(a4);
293   execution.push_transition(a5);
294 }
295
296 TEST_CASE("simgrid::mc::odpor::Execution: Independence Tests")
297 {
298   SECTION("Complete independence")
299   {
300     // Every transition is independent with every other and run by different actors. Hopefully
301     // we say that the events are independent with each other...
302     const auto a0 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
303     const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
304     const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
305     const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
306     const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 5);
307     const auto a5 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 6);
308     const auto a6 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 7);
309     const auto a7 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 7);
310     Execution execution;
311     execution.push_transition(a0);
312     execution.push_transition(a1);
313     execution.push_transition(a2);
314     execution.push_transition(a3);
315
316     REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a4, a5}, a6));
317     REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a6, a5}, a1));
318     REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a6, a1}, a0));
319     REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a7, a7, a1}, a3));
320     REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a4, a0, a1}, a3));
321     REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a0, a7, a1}, a2));
322
323     // In this case, we notice that `a6` and `a7` are executed by the same actor.
324     // Hence, a6 cannot be independent with extending the execution with a4.a5.a7.
325     // Notice that we are treating *a6* as the next step of actor 7 (that is what we
326     // supplied as an argument)
327     REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a4, a5, a7}, a6));
328   }
329
330   SECTION("Independence is trivial with an empty extension")
331   {
332     REQUIRE(Execution().is_independent_with_execution_of(
333         PartialExecution{}, std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1)));
334   }
335
336   SECTION("Dependencies stopping independence from being possible")
337   {
338     const auto a0    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
339     const auto a1    = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
340     const auto a2    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
341     const auto a3    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
342     const auto a4    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
343     const auto a5    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
344     const auto a6    = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
345     const auto a7    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
346     const auto a8    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
347     const auto indep = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
348     Execution execution;
349     execution.push_transition(a0);
350     execution.push_transition(a1);
351     execution.push_transition(a2);
352     execution.push_transition(a3);
353
354     // We see that although `a4` comes after `a1` with which it is dependent, it
355     // would come before "a6" in the partial execution `w`, so it would not be independent
356     REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a5, a6, a7}, a4));
357
358     // Removing `a6` from the picture, though, gives us the independence we're looking for.
359     REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a5, a7}, a4));
360
361     // BUT, we we ask about a transition which is run by the same actor, even if they would be
362     // independent otherwise, we again lose independence
363     REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a5, a7, a8}, a4));
364
365     // This is a more interesting case:
366     // `indep` clearly is independent with the rest of the series, even though
367     // there are dependencies among the other events in the partial execution
368     REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a1, a6, a7}, indep));
369
370     // This ensures that independence is trivial with an empty partial execution
371     REQUIRE(execution.is_independent_with_execution_of(PartialExecution{}, a1));
372   }
373 }
374
375 TEST_CASE("simgrid::mc::odpor::Execution: Initials Test")
376 {
377   const auto a0    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
378   const auto a1    = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
379   const auto a2    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
380   const auto a3    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
381   const auto a4    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
382   const auto a5    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
383   const auto a6    = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
384   const auto a7    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
385   const auto a8    = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
386   const auto indep = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
387   Execution execution;
388   execution.push_transition(a0);
389   execution.push_transition(a1);
390   execution.push_transition(a2);
391   execution.push_transition(a3);
392
393   SECTION("Initials trivial with empty executions")
394   {
395     // There are no initials for an empty extension since
396     // a requirement is that the actor be contained in the
397     // extension itself
398     REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 0));
399     REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 1));
400     REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 2));
401     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 0));
402     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 1));
403     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 2));
404   }
405
406   SECTION("The first actor is always an initial")
407   {
408     // Even in the case that the action is dependent with every
409     // other, if it is the first action to occur as part of the
410     // extension of the execution sequence, by definition it is
411     // an initial (recall that initials intuitively tell you which
412     // actions can be run starting from an execution `E`; if we claim
413     // to witness `E.w`, then clearly at least the first step of `w` is an initial)
414     REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a3}, a3->aid_));
415     REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a2, a3, a6}, a2->aid_));
416     REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a6, a1, a0}, a6->aid_));
417     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a0, a1, a2, a3}, a0->aid_));
418     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a5, a2, a8, a7, a6, a0}, a5->aid_));
419     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a8, a7, a1}, a8->aid_));
420   }
421
422   SECTION("Example: Disqualified and re-qualified after switching ordering")
423   {
424     // Even though actor `2` executes an independent
425     // transition later on, it is blocked since its first transition
426     // is dependent with actor 1's transition
427     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a5, indep}, 2));
428
429     // However, if actor 2 executes its independent action first, it DOES become an initial
430     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, indep, a5}, 2));
431   }
432
433   SECTION("Example: Large partial executions")
434   {
435     // The record trace is `1 3 4 4 3 1 4 2`
436
437     // Actor 1 starts the execution
438     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 1));
439
440     // Actor 2 all the way at the end is independent with everybody: despite
441     // the tangle that comes before it, we can more it to the front with no issue
442     REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 2));
443
444     // Actor 3 is eliminated since `a1` is dependent with `a2`
445     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 3));
446
447     // Likewise with actor 4
448     REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 4));
449   }
450 }
451
452 TEST_CASE("simgrid::mc::odpor::Execution: ODPOR Smallest Sequence Tests")
453 {
454   const auto a0 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
455   const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
456   const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
457   const auto a3 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
458   const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
459   const auto a5 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
460
461   Execution execution;
462   execution.push_transition(a0);
463   execution.push_transition(a1);
464   execution.push_transition(a2);
465   execution.push_transition(a3);
466   execution.push_transition(a4);
467   execution.push_transition(a5);
468
469   SECTION("Equivalent insertions")
470   {
471     SECTION("Example: Eliminated through independence")
472     {
473       // TODO: Is this even a sensible question to ask if the two sequences
474       // don't agree upon what each actor executed after `E`?
475       const auto insertion =
476           Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a2}, PartialExecution{a2, a5});
477       REQUIRE(insertion.has_value());
478       REQUIRE(insertion.value() == PartialExecution{});
479     }
480
481     SECTION("Exact match yields empty set")
482     {
483       const auto insertion =
484           Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a2}, PartialExecution{a1, a2});
485       REQUIRE(insertion.has_value());
486       REQUIRE(insertion.value() == PartialExecution{});
487     }
488   }
489
490   SECTION("Match against empty executions")
491   {
492     SECTION("Empty `v` trivially yields `w`")
493     {
494       auto insertion =
495           Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{}, PartialExecution{a1, a5, a2});
496       REQUIRE(insertion.has_value());
497       REQUIRE(insertion.value() == PartialExecution{a1, a5, a2});
498
499       insertion = execution.get_shortest_odpor_sq_subset_insertion(PartialExecution{}, PartialExecution{a1, a5, a2});
500       REQUIRE(insertion.has_value());
501       REQUIRE(insertion.value() == PartialExecution{a1, a5, a2});
502     }
503
504     SECTION("Empty `w` yields empty execution")
505     {
506       auto insertion =
507           Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a4, a5}, PartialExecution{});
508       REQUIRE(insertion.has_value());
509       REQUIRE(insertion.value() == PartialExecution{});
510
511       insertion = execution.get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a5, a2}, PartialExecution{});
512       REQUIRE(insertion.has_value());
513       REQUIRE(insertion.value() == PartialExecution{});
514     }
515   }
516
517   SECTION("") {}
518 }