Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add dependency between same actor for tests
[simgrid.git] / src / mc / explo / udpor / UnfoldingEvent_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/udpor/UnfoldingEvent.hpp"
8 #include "src/mc/explo/udpor/udpor_tests_private.hpp"
9
10 using namespace simgrid::mc;
11 using namespace simgrid::mc::udpor;
12
13 TEST_CASE("simgrid::mc::udpor::UnfoldingEvent: Semantic Equivalence Tests")
14 {
15   UnfoldingEvent e1(EventSet(), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
16   UnfoldingEvent e2(EventSet({&e1}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
17   UnfoldingEvent e3(EventSet({&e1}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
18   UnfoldingEvent e4(EventSet({&e1}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
19
20   UnfoldingEvent e5(EventSet({&e1, &e3, &e2}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
21   UnfoldingEvent e6(EventSet({&e1, &e3, &e2}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
22   UnfoldingEvent e7(EventSet({&e1, &e3, &e2}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
23
24   SECTION("Equivalence is an equivalence relation")
25   {
26     SECTION("Equivalence is reflexive")
27     {
28       REQUIRE(e1 == e1);
29       REQUIRE(e2 == e2);
30       REQUIRE(e3 == e3);
31       REQUIRE(e4 == e4);
32     }
33
34     SECTION("Equivalence is symmetric")
35     {
36       REQUIRE(e2 == e3);
37       REQUIRE(e3 == e2);
38       REQUIRE(e3 == e4);
39       REQUIRE(e4 == e3);
40       REQUIRE(e2 == e4);
41       REQUIRE(e4 == e2);
42     }
43
44     SECTION("Equivalence is transitive")
45     {
46       REQUIRE(e2 == e3);
47       REQUIRE(e3 == e4);
48       REQUIRE(e2 == e4);
49       REQUIRE(e5 == e6);
50       REQUIRE(e6 == e7);
51       REQUIRE(e5 == e7);
52     }
53   }
54
55   SECTION("Equivalence fails with different actors")
56   {
57     UnfoldingEvent e1_diff_actor(EventSet(), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1, 0));
58     UnfoldingEvent e2_diff_actor(EventSet({&e1}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 1, 0));
59     UnfoldingEvent e5_diff_actor(EventSet({&e1, &e3, &e2}),
60                                  std::make_shared<DependentAction>(Transition::Type::UNKNOWN, 1, 0));
61     REQUIRE(e1 != e1_diff_actor);
62     REQUIRE(e1 != e2_diff_actor);
63     REQUIRE(e1 != e5_diff_actor);
64   }
65
66   SECTION("Equivalence fails with different transition types")
67   {
68     // NOTE: We're comparing the transition `type_` field directly. To avoid
69     // modifying the `Type` enum that exists in `Transition` just for the tests,
70     // we instead provide different values of `Transition::Type` to simulate
71     // the different types
72     UnfoldingEvent e1_diff_transition(EventSet(),
73                                       std::make_shared<IndependentAction>(Transition::Type::ACTOR_JOIN, 0, 0));
74     UnfoldingEvent e2_diff_transition(EventSet({&e1}),
75                                       std::make_shared<IndependentAction>(Transition::Type::ACTOR_JOIN, 0, 0));
76     UnfoldingEvent e5_diff_transition(EventSet({&e1, &e3, &e2}),
77                                       std::make_shared<IndependentAction>(Transition::Type::ACTOR_JOIN, 0, 0));
78     REQUIRE(e1 != e1_diff_transition);
79     REQUIRE(e1 != e2_diff_transition);
80     REQUIRE(e1 != e5_diff_transition);
81   }
82
83   SECTION("Equivalence fails with different `times_considered`")
84   {
85     // With a different number for `times_considered`, we know
86     UnfoldingEvent e1_diff_considered(EventSet(), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 1));
87     UnfoldingEvent e2_diff_considered(EventSet({&e1}),
88                                       std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 1));
89     UnfoldingEvent e5_diff_considered(EventSet({&e1, &e3, &e2}),
90                                       std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 1));
91     REQUIRE(e1 != e1_diff_considered);
92     REQUIRE(e1 != e2_diff_considered);
93     REQUIRE(e1 != e5_diff_considered);
94   }
95
96   SECTION("Equivalence fails with different immediate histories of events")
97   {
98     UnfoldingEvent e1_diff_hist(EventSet({&e2}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
99     UnfoldingEvent e2_diff_hist(EventSet({&e3}), std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
100     UnfoldingEvent e5_diff_hist(EventSet({&e1, &e2}),
101                                 std::make_shared<IndependentAction>(Transition::Type::UNKNOWN, 0, 0));
102     REQUIRE(e1 != e1_diff_hist);
103     REQUIRE(e1 != e2_diff_hist);
104     REQUIRE(e1 != e5_diff_hist);
105   }
106 }
107
108 TEST_CASE("simgrid::mc::udpor::UnfoldingEvent: Dependency/Conflict Tests")
109 {
110   SECTION("Properties of the relations")
111   {
112     // The following tests concern the given event structure:
113     //                e1
114     //              /   /
115     //            e2    e6
116     //           /  /    /
117     //          e3   /   /
118     //         /  /    /
119     //        e4  e5   e7
120     //
121     // e5 and e6 are in conflict, e5 and e7 are in conflict, e2 and e6, and e2 ands e7 are in conflict
122     UnfoldingEvent e1(EventSet(), std::make_shared<ConditionallyDependentAction>(0));
123     UnfoldingEvent e2(EventSet({&e1}), std::make_shared<DependentAction>(0));
124     UnfoldingEvent e3(EventSet({&e2}), std::make_shared<IndependentAction>(0));
125     UnfoldingEvent e4(EventSet({&e3}), std::make_shared<ConditionallyDependentAction>(1));
126     UnfoldingEvent e5(EventSet({&e3}), std::make_shared<DependentAction>(1));
127     UnfoldingEvent e6(EventSet({&e1}), std::make_shared<ConditionallyDependentAction>(2));
128     UnfoldingEvent e7(EventSet({&e6, &e2}), std::make_shared<ConditionallyDependentAction>(3));
129
130     SECTION("Dependency relation properties")
131     {
132       SECTION("Dependency is reflexive")
133       {
134         REQUIRE(e2.is_dependent_with(&e2));
135         REQUIRE(e5.is_dependent_with(&e5));
136       }
137
138       SECTION("Dependency is symmetric")
139       {
140         REQUIRE(e2.is_dependent_with(&e6));
141         REQUIRE(e6.is_dependent_with(&e2));
142       }
143
144       SECTION("Dependency is NOT necessarily transitive")
145       {
146         REQUIRE(e1.is_dependent_with(&e5));
147         REQUIRE(e5.is_dependent_with(&e7));
148         REQUIRE_FALSE(e1.is_dependent_with(&e7));
149       }
150     }
151
152     SECTION("Conflict relation properties")
153     {
154       SECTION("Conflict relation is irreflexive")
155       {
156         REQUIRE_FALSE(e1.conflicts_with(&e1));
157         REQUIRE_FALSE(e2.conflicts_with(&e2));
158         REQUIRE_FALSE(e3.conflicts_with(&e3));
159         REQUIRE_FALSE(e4.conflicts_with(&e4));
160         REQUIRE_FALSE(e5.conflicts_with(&e5));
161         REQUIRE_FALSE(e6.conflicts_with(&e6));
162         REQUIRE_FALSE(e7.conflicts_with(&e7));
163
164         REQUIRE_FALSE(e1.immediately_conflicts_with(&e1));
165         REQUIRE_FALSE(e2.immediately_conflicts_with(&e2));
166         REQUIRE_FALSE(e3.immediately_conflicts_with(&e3));
167         REQUIRE_FALSE(e4.immediately_conflicts_with(&e4));
168         REQUIRE_FALSE(e5.immediately_conflicts_with(&e5));
169         REQUIRE_FALSE(e6.immediately_conflicts_with(&e6));
170         REQUIRE_FALSE(e7.immediately_conflicts_with(&e7));
171       }
172
173       SECTION("Conflict relation is symmetric")
174       {
175         REQUIRE(e5.conflicts_with(&e6));
176         REQUIRE(e6.conflicts_with(&e5));
177         REQUIRE(e5.immediately_conflicts_with(&e4));
178         REQUIRE(e4.immediately_conflicts_with(&e5));
179       }
180     }
181   }
182
183   SECTION("Testing with no dependencies whatsoever")
184   {
185     // The following tests concern the given event structure:
186     //                e1
187     //              /   /
188     //            e2    e6
189     //           /  /    /
190     //          e3   /   /
191     //         /  /    /
192     //        e4  e5   e7
193     UnfoldingEvent e1(EventSet(), std::make_shared<IndependentAction>(0));
194     UnfoldingEvent e2(EventSet({&e1}), std::make_shared<IndependentAction>(1));
195     UnfoldingEvent e3(EventSet({&e2}), std::make_shared<IndependentAction>(2));
196     UnfoldingEvent e4(EventSet({&e3}), std::make_shared<IndependentAction>(3));
197     UnfoldingEvent e5(EventSet({&e3}), std::make_shared<IndependentAction>(4));
198     UnfoldingEvent e6(EventSet({&e1}), std::make_shared<IndependentAction>(5));
199     UnfoldingEvent e7(EventSet({&e6, &e2}), std::make_shared<IndependentAction>(6));
200
201     // Since everyone's actions are independent of one another, we expect
202     // that there are no conflicts between each pair of events (except with
203     // the same event itself)
204     SECTION("Mutual dependencies")
205     {
206       CHECK(e1.is_dependent_with(&e1));
207       CHECK_FALSE(e1.is_dependent_with(&e2));
208       CHECK_FALSE(e1.is_dependent_with(&e3));
209       CHECK_FALSE(e1.is_dependent_with(&e4));
210       CHECK_FALSE(e1.is_dependent_with(&e5));
211       CHECK_FALSE(e1.is_dependent_with(&e6));
212       CHECK_FALSE(e1.is_dependent_with(&e7));
213
214       CHECK(e2.is_dependent_with(&e2));
215       CHECK_FALSE(e2.is_dependent_with(&e3));
216       CHECK_FALSE(e2.is_dependent_with(&e4));
217       CHECK_FALSE(e2.is_dependent_with(&e5));
218       CHECK_FALSE(e2.is_dependent_with(&e6));
219       CHECK_FALSE(e2.is_dependent_with(&e7));
220
221       CHECK(e3.is_dependent_with(&e3));
222       CHECK_FALSE(e3.is_dependent_with(&e4));
223       CHECK_FALSE(e3.is_dependent_with(&e5));
224       CHECK_FALSE(e3.is_dependent_with(&e6));
225       CHECK_FALSE(e3.is_dependent_with(&e7));
226
227       CHECK(e4.is_dependent_with(&e4));
228       CHECK_FALSE(e4.is_dependent_with(&e5));
229       CHECK_FALSE(e4.is_dependent_with(&e6));
230       CHECK_FALSE(e4.is_dependent_with(&e7));
231
232       CHECK(e5.is_dependent_with(&e5));
233       CHECK_FALSE(e5.is_dependent_with(&e6));
234       CHECK_FALSE(e5.is_dependent_with(&e7));
235
236       CHECK(e6.is_dependent_with(&e6));
237       CHECK_FALSE(e6.is_dependent_with(&e7));
238
239       CHECK(e7.is_dependent_with(&e7));
240     }
241
242     SECTION("Mutual conflicts")
243     {
244       CHECK_FALSE(e1.conflicts_with(&e1));
245       CHECK_FALSE(e1.conflicts_with(&e2));
246       CHECK_FALSE(e1.conflicts_with(&e3));
247       CHECK_FALSE(e1.conflicts_with(&e4));
248       CHECK_FALSE(e1.conflicts_with(&e5));
249       CHECK_FALSE(e1.conflicts_with(&e6));
250       CHECK_FALSE(e1.conflicts_with(&e7));
251
252       CHECK_FALSE(e2.conflicts_with(&e1));
253       CHECK_FALSE(e2.conflicts_with(&e2));
254       CHECK_FALSE(e2.conflicts_with(&e3));
255       CHECK_FALSE(e2.conflicts_with(&e4));
256       CHECK_FALSE(e2.conflicts_with(&e5));
257       CHECK_FALSE(e2.conflicts_with(&e6));
258       CHECK_FALSE(e2.conflicts_with(&e7));
259
260       CHECK_FALSE(e3.conflicts_with(&e1));
261       CHECK_FALSE(e3.conflicts_with(&e2));
262       CHECK_FALSE(e3.conflicts_with(&e3));
263       CHECK_FALSE(e3.conflicts_with(&e4));
264       CHECK_FALSE(e3.conflicts_with(&e5));
265       CHECK_FALSE(e3.conflicts_with(&e6));
266       CHECK_FALSE(e3.conflicts_with(&e7));
267
268       CHECK_FALSE(e4.conflicts_with(&e1));
269       CHECK_FALSE(e4.conflicts_with(&e2));
270       CHECK_FALSE(e4.conflicts_with(&e3));
271       CHECK_FALSE(e4.conflicts_with(&e4));
272       CHECK_FALSE(e4.conflicts_with(&e5));
273       CHECK_FALSE(e4.conflicts_with(&e6));
274       CHECK_FALSE(e4.conflicts_with(&e7));
275
276       CHECK_FALSE(e5.conflicts_with(&e1));
277       CHECK_FALSE(e5.conflicts_with(&e2));
278       CHECK_FALSE(e5.conflicts_with(&e3));
279       CHECK_FALSE(e5.conflicts_with(&e4));
280       CHECK_FALSE(e5.conflicts_with(&e5));
281       CHECK_FALSE(e5.conflicts_with(&e6));
282       CHECK_FALSE(e5.conflicts_with(&e7));
283
284       CHECK_FALSE(e6.conflicts_with(&e1));
285       CHECK_FALSE(e6.conflicts_with(&e2));
286       CHECK_FALSE(e6.conflicts_with(&e3));
287       CHECK_FALSE(e6.conflicts_with(&e4));
288       CHECK_FALSE(e6.conflicts_with(&e5));
289       CHECK_FALSE(e6.conflicts_with(&e6));
290       CHECK_FALSE(e6.conflicts_with(&e7));
291
292       CHECK_FALSE(e7.conflicts_with(&e1));
293       CHECK_FALSE(e7.conflicts_with(&e2));
294       CHECK_FALSE(e7.conflicts_with(&e3));
295       CHECK_FALSE(e7.conflicts_with(&e4));
296       CHECK_FALSE(e7.conflicts_with(&e5));
297       CHECK_FALSE(e7.conflicts_with(&e6));
298       CHECK_FALSE(e7.conflicts_with(&e7));
299     }
300   }
301
302   SECTION("Testing with some conflicts")
303   {
304     // The following tests concern the given event structure:
305     //                e1
306     //              /   /
307     //            e2    e6
308     //           /  /    /
309     //          e3   /   /
310     //         /  /    /
311     //        e4  e5   e7
312     UnfoldingEvent e1(EventSet(), std::make_shared<DependentAction>(0));
313     UnfoldingEvent e2(EventSet({&e1}), std::make_shared<DependentAction>(1));
314     UnfoldingEvent e3(EventSet({&e2}), std::make_shared<IndependentAction>(2));
315     UnfoldingEvent e4(EventSet({&e3}), std::make_shared<IndependentAction>(3));
316     UnfoldingEvent e5(EventSet({&e3}), std::make_shared<IndependentAction>(4));
317     UnfoldingEvent e6(EventSet({&e1}), std::make_shared<IndependentAction>(5));
318     UnfoldingEvent e7(EventSet({&e6, &e2}), std::make_shared<ConditionallyDependentAction>(6));
319
320     // Since everyone's actions are independent of one another, we expect
321     // that there are no conflicts between each pair of events (except the pair
322     // with the event and itself)
323     SECTION("Mutual dependencies")
324     {
325       CHECK(e1.is_dependent_with(&e1));
326       CHECK(e1.is_dependent_with(&e2));
327       CHECK_FALSE(e1.is_dependent_with(&e3));
328       CHECK_FALSE(e1.is_dependent_with(&e4));
329       CHECK_FALSE(e1.is_dependent_with(&e5));
330       CHECK_FALSE(e1.is_dependent_with(&e6));
331       CHECK(e1.is_dependent_with(&e7));
332
333       CHECK(e2.is_dependent_with(&e2));
334       CHECK_FALSE(e2.is_dependent_with(&e3));
335       CHECK_FALSE(e2.is_dependent_with(&e4));
336       CHECK_FALSE(e2.is_dependent_with(&e5));
337       CHECK_FALSE(e2.is_dependent_with(&e6));
338       CHECK(e2.is_dependent_with(&e7));
339
340       CHECK(e3.is_dependent_with(&e3));
341       CHECK_FALSE(e3.is_dependent_with(&e4));
342       CHECK_FALSE(e3.is_dependent_with(&e5));
343       CHECK_FALSE(e3.is_dependent_with(&e6));
344       CHECK_FALSE(e3.is_dependent_with(&e7));
345
346       CHECK(e4.is_dependent_with(&e4));
347       CHECK_FALSE(e4.is_dependent_with(&e5));
348       CHECK_FALSE(e4.is_dependent_with(&e6));
349       CHECK_FALSE(e4.is_dependent_with(&e7));
350
351       CHECK(e5.is_dependent_with(&e5));
352       CHECK_FALSE(e5.is_dependent_with(&e6));
353       CHECK_FALSE(e5.is_dependent_with(&e7));
354
355       CHECK(e6.is_dependent_with(&e6));
356       CHECK_FALSE(e6.is_dependent_with(&e7));
357
358       CHECK(e7.is_dependent_with(&e7));
359     }
360
361     SECTION("Mutual conflicts")
362     {
363       // Although e1 is dependent with e1, e2, and e7,
364       // since they are related to one another, they are not
365       // considered to be in conflict
366       CHECK_FALSE(e1.conflicts_with(&e1));
367       CHECK_FALSE(e1.conflicts_with(&e2));
368       CHECK_FALSE(e1.conflicts_with(&e3));
369       CHECK_FALSE(e1.conflicts_with(&e4));
370       CHECK_FALSE(e1.conflicts_with(&e5));
371       CHECK_FALSE(e1.conflicts_with(&e6));
372       CHECK_FALSE(e1.conflicts_with(&e7));
373
374       // Same goes for e2 with e2 and e7
375       CHECK_FALSE(e2.conflicts_with(&e1));
376       CHECK_FALSE(e2.conflicts_with(&e2));
377       CHECK_FALSE(e2.conflicts_with(&e3));
378       CHECK_FALSE(e2.conflicts_with(&e4));
379       CHECK_FALSE(e2.conflicts_with(&e5));
380       CHECK_FALSE(e2.conflicts_with(&e6));
381       CHECK_FALSE(e2.conflicts_with(&e7));
382
383       CHECK_FALSE(e3.conflicts_with(&e1));
384       CHECK_FALSE(e3.conflicts_with(&e2));
385       CHECK_FALSE(e3.conflicts_with(&e3));
386       CHECK_FALSE(e3.conflicts_with(&e4));
387       CHECK_FALSE(e3.conflicts_with(&e5));
388       CHECK_FALSE(e3.conflicts_with(&e6));
389       CHECK_FALSE(e3.conflicts_with(&e7));
390
391       CHECK_FALSE(e4.conflicts_with(&e1));
392       CHECK_FALSE(e4.conflicts_with(&e2));
393       CHECK_FALSE(e4.conflicts_with(&e3));
394       CHECK_FALSE(e4.conflicts_with(&e4));
395       CHECK_FALSE(e4.conflicts_with(&e5));
396       CHECK_FALSE(e4.conflicts_with(&e6));
397       CHECK_FALSE(e4.conflicts_with(&e7));
398
399       CHECK_FALSE(e5.conflicts_with(&e1));
400       CHECK_FALSE(e5.conflicts_with(&e2));
401       CHECK_FALSE(e5.conflicts_with(&e3));
402       CHECK_FALSE(e5.conflicts_with(&e4));
403       CHECK_FALSE(e5.conflicts_with(&e5));
404       CHECK_FALSE(e5.conflicts_with(&e6));
405       CHECK_FALSE(e5.conflicts_with(&e7));
406
407       CHECK_FALSE(e6.conflicts_with(&e1));
408       CHECK_FALSE(e6.conflicts_with(&e2));
409       CHECK_FALSE(e6.conflicts_with(&e3));
410       CHECK_FALSE(e6.conflicts_with(&e4));
411       CHECK_FALSE(e6.conflicts_with(&e5));
412       CHECK_FALSE(e6.conflicts_with(&e6));
413       CHECK_FALSE(e6.conflicts_with(&e7));
414
415       CHECK_FALSE(e7.conflicts_with(&e1));
416       CHECK_FALSE(e7.conflicts_with(&e2));
417       CHECK_FALSE(e7.conflicts_with(&e3));
418       CHECK_FALSE(e7.conflicts_with(&e4));
419       CHECK_FALSE(e7.conflicts_with(&e5));
420       CHECK_FALSE(e7.conflicts_with(&e6));
421       CHECK_FALSE(e7.conflicts_with(&e7));
422     }
423   }
424
425   SECTION("More complicated conflicts")
426   {
427     // The following tests concern the given event structure:
428     //                e1
429     //              /   /
430     //            e2    e6
431     //           /      /
432     //          e3      /
433     //         /  /    e7
434     //        e4  e5
435     UnfoldingEvent e1(EventSet(), std::make_shared<IndependentAction>(0));
436     UnfoldingEvent e2(EventSet({&e1}), std::make_shared<ConditionallyDependentAction>(1));
437     UnfoldingEvent e3(EventSet({&e2}), std::make_shared<IndependentAction>(2));
438     UnfoldingEvent e4(EventSet({&e3}), std::make_shared<IndependentAction>(3));
439     UnfoldingEvent e5(EventSet({&e3}), std::make_shared<IndependentAction>(4));
440     UnfoldingEvent e6(EventSet({&e1}), std::make_shared<DependentAction>(5));
441     UnfoldingEvent e7(EventSet({&e6}), std::make_shared<IndependentAction>(6));
442
443     CHECK_FALSE(e1.conflicts_with(&e1));
444     CHECK_FALSE(e1.conflicts_with(&e2));
445     CHECK_FALSE(e1.conflicts_with(&e3));
446     CHECK_FALSE(e1.conflicts_with(&e4));
447     CHECK_FALSE(e1.conflicts_with(&e5));
448     CHECK_FALSE(e1.conflicts_with(&e6));
449     CHECK_FALSE(e1.conflicts_with(&e7));
450
451     // e2 conflicts with e6. Since e6 < e7,
452     // e2 also conflicts with e7
453     CHECK_FALSE(e2.conflicts_with(&e1));
454     CHECK_FALSE(e2.conflicts_with(&e2));
455     CHECK_FALSE(e2.conflicts_with(&e3));
456     CHECK_FALSE(e2.conflicts_with(&e4));
457     CHECK_FALSE(e2.conflicts_with(&e5));
458     CHECK(e2.conflicts_with(&e6));
459     REQUIRE(e2.conflicts_with(&e7));
460
461     // e3 and e6 are dependent and unrelated, so they conflict
462     CHECK_FALSE(e3.conflicts_with(&e1));
463     CHECK_FALSE(e3.conflicts_with(&e2));
464     CHECK_FALSE(e3.conflicts_with(&e3));
465     CHECK_FALSE(e3.conflicts_with(&e4));
466     CHECK_FALSE(e3.conflicts_with(&e5));
467     CHECK(e3.conflicts_with(&e6));
468     CHECK_FALSE(e3.conflicts_with(&e7));
469
470     // Since e3 and e6 conflict and e3 < e4, e4 and e6 conflict
471     CHECK_FALSE(e4.conflicts_with(&e1));
472     CHECK_FALSE(e4.conflicts_with(&e2));
473     CHECK_FALSE(e4.conflicts_with(&e3));
474     CHECK_FALSE(e4.conflicts_with(&e4));
475     CHECK_FALSE(e4.conflicts_with(&e5));
476     CHECK(e4.conflicts_with(&e6));
477     CHECK_FALSE(e4.conflicts_with(&e7));
478
479     // Likewise for e5
480     CHECK_FALSE(e5.conflicts_with(&e1));
481     CHECK_FALSE(e5.conflicts_with(&e2));
482     CHECK_FALSE(e5.conflicts_with(&e3));
483     CHECK_FALSE(e5.conflicts_with(&e4));
484     CHECK_FALSE(e5.conflicts_with(&e5));
485     CHECK(e5.conflicts_with(&e6));
486     CHECK_FALSE(e5.conflicts_with(&e7));
487
488     // Conflicts are symmetric
489     CHECK_FALSE(e6.conflicts_with(&e1));
490     CHECK(e6.conflicts_with(&e2));
491     CHECK(e6.conflicts_with(&e3));
492     CHECK(e6.conflicts_with(&e4));
493     CHECK(e6.conflicts_with(&e5));
494     CHECK_FALSE(e6.conflicts_with(&e6));
495     CHECK_FALSE(e6.conflicts_with(&e7));
496
497     CHECK_FALSE(e7.conflicts_with(&e1));
498     CHECK(e7.conflicts_with(&e2));
499     CHECK_FALSE(e7.conflicts_with(&e3));
500     CHECK_FALSE(e7.conflicts_with(&e4));
501     CHECK_FALSE(e7.conflicts_with(&e5));
502     CHECK_FALSE(e7.conflicts_with(&e6));
503     CHECK_FALSE(e7.conflicts_with(&e7));
504   }
505 }
506
507 TEST_CASE("simgrid::mc::udpor::UnfoldingEvent: Immediate Conflicts + Conflicts Stress Test")
508 {
509   // The following tests concern the given event structure:
510   //                e1
511   //              /  / /
512   //            e2  e3  e4
513   //                 / /  /
514   //                 e5   e10
515   //                  /
516   //                 e6
517   //                 / /
518   //               e7  e8
519   //                    /
520   //                    e9
521   //
522   // Immediate conflicts:
523   // e2 + e3
524   // e3 + e4
525   // e2 + e4
526   //
527   // NOTE: e7 + e8 ARE NOT in immediate conflict! The reason is that
528   // the set of events {e8, e6, e5, e3, e4, e1} is not a valid configuration,
529   // (nor is {e7, e6, e5, e3, e4, e1})
530   //
531   // NOTE: e2/e3 + e10 are NOT in immediate conflict! EVEN THOUGH {e1, e4, e10}
532   // is a valid configuration, {e1, e2/e3, e4} is not (since e2/e3 and e4 conflict)
533   UnfoldingEvent e1(EventSet(), std::make_shared<IndependentAction>());
534   UnfoldingEvent e2(EventSet({&e1}), std::make_shared<DependentAction>());
535   UnfoldingEvent e3(EventSet({&e1}), std::make_shared<DependentAction>());
536   UnfoldingEvent e4(EventSet({&e1}), std::make_shared<DependentAction>());
537   UnfoldingEvent e5(EventSet({&e3, &e4}), std::make_shared<IndependentAction>());
538   UnfoldingEvent e6(EventSet({&e5}), std::make_shared<IndependentAction>());
539   UnfoldingEvent e7(EventSet({&e6}), std::make_shared<DependentAction>());
540   UnfoldingEvent e8(EventSet({&e6}), std::make_shared<DependentAction>());
541   UnfoldingEvent e9(EventSet({&e8}), std::make_shared<IndependentAction>());
542   UnfoldingEvent e10(EventSet({&e4}), std::make_shared<DependentAction>());
543
544   REQUIRE(e2.immediately_conflicts_with(&e3));
545   REQUIRE(e3.immediately_conflicts_with(&e4));
546   REQUIRE(e2.immediately_conflicts_with(&e4));
547
548   REQUIRE(e2.conflicts_with(&e10));
549   REQUIRE(e3.conflicts_with(&e10));
550   REQUIRE(e7.conflicts_with(&e8));
551   REQUIRE_FALSE(e2.immediately_conflicts_with(&e10));
552   REQUIRE_FALSE(e3.immediately_conflicts_with(&e10));
553   REQUIRE_FALSE(e7.immediately_conflicts_with(&e8));
554 }