1 /* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved. */
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. */
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"
11 using namespace simgrid::mc;
12 using namespace simgrid::mc::odpor;
13 using namespace simgrid::mc::udpor;
15 TEST_CASE("simgrid::mc::odpor::Execution: Constructing Executions")
18 REQUIRE(execution.empty());
19 REQUIRE(execution.size() == 0);
20 REQUIRE_FALSE(execution.get_latest_event_handle().has_value());
23 TEST_CASE("simgrid::mc::odpor::Execution: Testing Happens-Before")
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);
35 execution.push_transition(a1);
36 execution.push_transition(a2);
37 execution.push_transition(a3);
38 execution.push_transition(a4);
40 SECTION("Happens-before is irreflexive")
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));
48 SECTION("Happens-before values for each pair of events")
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));
58 SECTION("Happens-before is a subset of 'occurs-before' ")
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));
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);
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"
81 execution.push_transition(a1);
82 execution.push_transition(a2);
83 execution.push_transition(a3);
84 execution.push_transition(a4);
86 SECTION("Happens-before is irreflexive")
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));
94 SECTION("Happens-before values for each pair of events")
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));
104 SECTION("Happens-before is a subset of 'occurs-before'")
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));
116 TEST_CASE("simgrid::mc::odpor::Execution: Testing Racing Events and Initials")
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);
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);
133 // Nothing comes before event 0
134 REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
136 // Events 0 and 1 are independent
137 REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
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});
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>{});
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
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});
153 SECTION("Example 2: Events with multiple races")
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);
161 execution.push_transition(a1);
162 execution.push_transition(a2);
163 execution.push_transition(a3);
164 execution.push_transition(a4);
166 // Nothing comes before event 0
167 REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
169 // Events 0 and 1 are independent
170 REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
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>{});
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});
178 SECTION("Check initials with respect to event 1")
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_first_sdpor_initial_from(1, std::unordered_set<aid_t>{});
185 REQUIRE(initial_wrt_event1.has_value());
186 REQUIRE(initial_wrt_event1.value() == static_cast<aid_t>(1));
189 SECTION("Check initials with respect to event 2")
191 // First, note that v := notdep(1, execution).p == {}.{e3} == {e3}
192 // e3 has nothing happening before it in dom_E(v), so it is an initial
194 const auto initial_wrt_event2 = execution.get_first_sdpor_initial_from(2, std::unordered_set<aid_t>{});
195 REQUIRE(initial_wrt_event2.has_value());
196 REQUIRE(initial_wrt_event2.value() == static_cast<aid_t>(3));
200 SECTION("Example 3: Testing 'Lock' Example")
203 const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
204 const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
205 const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
206 const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
207 const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
210 execution.push_transition(a1);
211 execution.push_transition(a2);
212 execution.push_transition(a3);
213 execution.push_transition(a4);
214 execution.push_transition(a5);
216 REQUIRE(execution.get_racing_events_of(4) == std::unordered_set<Execution::EventHandle>{0});
219 SECTION("Example 4: Indirect Races")
221 const auto a0 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
222 const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
223 const auto a2 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
224 const auto a3 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
225 const auto a4 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 6);
226 const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
227 const auto a6 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
228 const auto a7 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
229 const auto a8 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
230 const auto a9 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
233 execution.push_transition(a0);
234 execution.push_transition(a1);
235 execution.push_transition(a2);
236 execution.push_transition(a3);
237 execution.push_transition(a4);
238 execution.push_transition(a5);
239 execution.push_transition(a6);
240 execution.push_transition(a7);
241 execution.push_transition(a8);
242 execution.push_transition(a9);
244 // Nothing comes before event 0
245 REQUIRE(execution.get_racing_events_of(0) == std::unordered_set<Execution::EventHandle>{});
247 // Events 0 and 1 are independent
248 REQUIRE(execution.get_racing_events_of(1) == std::unordered_set<Execution::EventHandle>{});
250 // Events 1 and 2 are independent
251 REQUIRE(execution.get_racing_events_of(2) == std::unordered_set<Execution::EventHandle>{});
253 // Events 1 and 3 are independent; the rest are executed by the same actor
254 REQUIRE(execution.get_racing_events_of(3) == std::unordered_set<Execution::EventHandle>{});
256 // 1. Events 3 and 4 race
257 // 2. Events 2 and 4 do NOT race since 2 --> 3 --> 4
258 // 3. Events 1 and 4 do NOT race since 1 is independent of 4
259 // 4. Events 0 and 4 do NOT race since 0 --> 2 --> 4
260 REQUIRE(execution.get_racing_events_of(4) == std::unordered_set<Execution::EventHandle>{3});
262 // Events 4 and 5 race; and because everyone before 4 (including 3) either
263 // a) happens-before, b) races, or c) does not race with 4, 4 is the race
264 REQUIRE(execution.get_racing_events_of(5) == std::unordered_set<Execution::EventHandle>{4});
266 // The same logic that applied to event 5 applies to event 6
267 REQUIRE(execution.get_racing_events_of(6) == std::unordered_set<Execution::EventHandle>{5});
269 // The same logic applies, except that this time since events 6 and 7 are run
270 // by the same actor, they don'tt actually race with one another
271 REQUIRE(execution.get_racing_events_of(7) == std::unordered_set<Execution::EventHandle>{});
273 // Event 8 is independent with everything
274 REQUIRE(execution.get_racing_events_of(8) == std::unordered_set<Execution::EventHandle>{});
276 // Event 9 is independent with events 7 and 8; event 6, however, is in race with 9.
277 // The same logic above eliminates events before 6
278 REQUIRE(execution.get_racing_events_of(9) == std::unordered_set<Execution::EventHandle>{6});
282 TEST_CASE("simgrid::mc::odpor::Execution: Testing Races and Conditions")
284 const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
285 const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
286 const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
287 const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
288 const auto a5 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
291 execution.push_transition(a1);
292 execution.push_transition(a2);
293 execution.push_transition(a3);
294 execution.push_transition(a4);
295 execution.push_transition(a5);
298 TEST_CASE("simgrid::mc::odpor::Execution: Independence Tests")
300 SECTION("Complete independence")
302 // Every transition is independent with every other and run by different actors. Hopefully
303 // we say that the events are independent with each other...
304 const auto a0 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1);
305 const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
306 const auto a2 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 3);
307 const auto a3 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
308 const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 5);
309 const auto a5 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 6);
310 const auto a6 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 7);
311 const auto a7 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 7);
313 execution.push_transition(a0);
314 execution.push_transition(a1);
315 execution.push_transition(a2);
316 execution.push_transition(a3);
318 REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a4, a5}, a6));
319 REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a6, a5}, a1));
320 REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a6, a1}, a0));
321 REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a7, a7, a1}, a3));
322 REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a4, a0, a1}, a3));
323 REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a0, a7, a1}, a2));
325 // In this case, we notice that `a6` and `a7` are executed by the same actor.
326 // Hence, a6 cannot be independent with extending the execution with a4.a5.a7.
327 // Notice that we are treating *a6* as the next step of actor 7 (that is what we
328 // supplied as an argument)
329 REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a4, a5, a7}, a6));
332 SECTION("Independence is trivial with an empty extension")
334 REQUIRE(Execution().is_independent_with_execution_of(
335 PartialExecution{}, std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1)));
338 SECTION("Dependencies stopping independence from being possible")
340 const auto a0 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
341 const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
342 const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
343 const auto a3 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
344 const auto a4 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
345 const auto a5 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
346 const auto a6 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
347 const auto a7 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
348 const auto a8 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
349 const auto indep = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
351 execution.push_transition(a0);
352 execution.push_transition(a1);
353 execution.push_transition(a2);
354 execution.push_transition(a3);
356 // We see that although `a4` comes after `a1` with which it is dependent, it
357 // would come before "a6" in the partial execution `w`, so it would not be independent
358 REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a5, a6, a7}, a4));
360 // Removing `a6` from the picture, though, gives us the independence we're looking for.
361 REQUIRE(execution.is_independent_with_execution_of(PartialExecution{a5, a7}, a4));
363 // BUT, we we ask about a transition which is run by the same actor, even if they would be
364 // independent otherwise, we again lose independence
365 REQUIRE_FALSE(execution.is_independent_with_execution_of(PartialExecution{a5, a7, a8}, a4));
367 // This is a more interesting case:
368 // `indep` clearly is independent with the rest of the series, even though
369 // there are dependencies among the other events in the partial execution
370 REQUIRE(Execution().is_independent_with_execution_of(PartialExecution{a1, a6, a7}, indep));
372 // This ensures that independence is trivial with an empty partial execution
373 REQUIRE(execution.is_independent_with_execution_of(PartialExecution{}, a1));
377 TEST_CASE("simgrid::mc::odpor::Execution: Initials Test")
379 const auto a0 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
380 const auto a1 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
381 const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
382 const auto a3 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
383 const auto a4 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
384 const auto a5 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 2);
385 const auto a6 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 3);
386 const auto a7 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 1);
387 const auto a8 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
388 const auto indep = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
390 execution.push_transition(a0);
391 execution.push_transition(a1);
392 execution.push_transition(a2);
393 execution.push_transition(a3);
395 SECTION("Initials trivial with empty executions")
397 // There are no initials for an empty extension since
398 // a requirement is that the actor be contained in the
400 REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 0));
401 REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 1));
402 REQUIRE_FALSE(execution.is_initial_after_execution_of(PartialExecution{}, 2));
403 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 0));
404 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 1));
405 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{}, 2));
408 SECTION("The first actor is always an initial")
410 // Even in the case that the action is dependent with every
411 // other, if it is the first action to occur as part of the
412 // extension of the execution sequence, by definition it is
413 // an initial (recall that initials intuitively tell you which
414 // actions can be run starting from an execution `E`; if we claim
415 // to witness `E.w`, then clearly at least the first step of `w` is an initial)
416 REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a3}, a3->aid_));
417 REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a2, a3, a6}, a2->aid_));
418 REQUIRE(execution.is_initial_after_execution_of(PartialExecution{a6, a1, a0}, a6->aid_));
419 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a0, a1, a2, a3}, a0->aid_));
420 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a5, a2, a8, a7, a6, a0}, a5->aid_));
421 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a8, a7, a1}, a8->aid_));
424 SECTION("Example: Disqualified and re-qualified after switching ordering")
426 // Even though actor `2` executes an independent
427 // transition later on, it is blocked since its first transition
428 // is dependent with actor 1's transition
429 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a5, indep}, 2));
431 // However, if actor 2 executes its independent action first, it DOES become an initial
432 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, indep, a5}, 2));
435 SECTION("Example: Large partial executions")
437 // The record trace is `1 3 4 4 3 1 4 2`
439 // Actor 1 starts the execution
440 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 1));
442 // Actor 2 all the way at the end is independent with everybody: despite
443 // the tangle that comes before it, we can more it to the front with no issue
444 REQUIRE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 2));
446 // Actor 3 is eliminated since `a1` is dependent with `a2`
447 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 3));
449 // Likewise with actor 4
450 REQUIRE_FALSE(Execution().is_initial_after_execution_of(PartialExecution{a1, a2, a3, a4, a6, a7, a8, indep}, 4));
454 TEST_CASE("simgrid::mc::odpor::Execution: ODPOR Smallest Sequence Tests")
456 const auto a0 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 2);
457 const auto a1 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 4);
458 const auto a2 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 3);
459 const auto a3 = std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1);
460 const auto a4 = std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 2);
461 const auto a5 = std::make_shared<ConditionallyDependentAction>(Transition::Type::UNKNOWN, 4);
464 execution.push_transition(a0);
465 execution.push_transition(a1);
466 execution.push_transition(a2);
467 execution.push_transition(a3);
468 execution.push_transition(a4);
469 execution.push_transition(a5);
471 SECTION("Equivalent insertions")
473 SECTION("Example: Eliminated through independence")
475 // TODO: Is this even a sensible question to ask if the two sequences
476 // don't agree upon what each actor executed after `E`?
477 const auto insertion =
478 Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a2}, PartialExecution{a2, a5});
479 REQUIRE(insertion.has_value());
480 REQUIRE(insertion.value() == PartialExecution{});
483 SECTION("Exact match yields empty set")
485 const auto insertion =
486 Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a2}, PartialExecution{a1, a2});
487 REQUIRE(insertion.has_value());
488 REQUIRE(insertion.value() == PartialExecution{});
492 SECTION("Match against empty executions")
494 SECTION("Empty `v` trivially yields `w`")
497 Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{}, PartialExecution{a1, a5, a2});
498 REQUIRE(insertion.has_value());
499 REQUIRE(insertion.value() == PartialExecution{a1, a5, a2});
501 insertion = execution.get_shortest_odpor_sq_subset_insertion(PartialExecution{}, PartialExecution{a1, a5, a2});
502 REQUIRE(insertion.has_value());
503 REQUIRE(insertion.value() == PartialExecution{a1, a5, a2});
506 SECTION("Empty `w` yields empty execution")
509 Execution().get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a4, a5}, PartialExecution{});
510 REQUIRE(insertion.has_value());
511 REQUIRE(insertion.value() == PartialExecution{});
513 insertion = execution.get_shortest_odpor_sq_subset_insertion(PartialExecution{a1, a5, a2}, PartialExecution{});
514 REQUIRE(insertion.has_value());
515 REQUIRE(insertion.value() == PartialExecution{});