Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'udpor-phase6' into 'master'
[simgrid.git] / src / mc / explo / udpor / Unfolding_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/Unfolding.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::Unfolding: Creating an unfolding")
14 {
15   Unfolding unfolding;
16   REQUIRE(unfolding.size() == 0);
17   REQUIRE(unfolding.empty());
18 }
19
20 TEST_CASE("simgrid::mc::udpor::Unfolding: Inserting and removing events with an unfolding")
21 {
22   Unfolding unfolding;
23   auto e1              = std::make_unique<UnfoldingEvent>();
24   auto e2              = std::make_unique<UnfoldingEvent>();
25   const auto e1_handle = e1.get();
26   const auto e2_handle = e2.get();
27
28   unfolding.insert(std::move(e1));
29   REQUIRE(unfolding.size() == 1);
30   REQUIRE_FALSE(unfolding.empty());
31
32   unfolding.insert(std::move(e2));
33   REQUIRE(unfolding.size() == 2);
34   REQUIRE_FALSE(unfolding.empty());
35
36   unfolding.remove(e1_handle);
37   REQUIRE(unfolding.size() == 1);
38   REQUIRE_FALSE(unfolding.empty());
39
40   unfolding.remove(e2_handle);
41   REQUIRE(unfolding.size() == 0);
42   REQUIRE(unfolding.empty());
43 }
44
45 TEST_CASE("simgrid::mc::udpor::Unfolding: Checking for semantically equivalent events")
46 {
47   Unfolding unfolding;
48   auto e1 = std::make_unique<UnfoldingEvent>(
49       EventSet(), std::make_shared<IndependentAction>(Transition::Type::BARRIER_ASYNC_LOCK, 6, 2));
50   auto e2 = std::make_unique<UnfoldingEvent>(
51       EventSet(), std::make_shared<IndependentAction>(Transition::Type::BARRIER_ASYNC_LOCK, 6, 2));
52
53   // e1 and e2 are equivalent
54   REQUIRE(*e1 == *e2);
55
56   const auto e1_handle = e1.get();
57   const auto e2_handle = e2.get();
58   unfolding.insert(std::move(e1));
59
60   REQUIRE(unfolding.contains_event_equivalent_to(e1_handle));
61   REQUIRE(unfolding.contains_event_equivalent_to(e2_handle));
62 }
63
64 TEST_CASE("simgrid::mc::udpor::Unfolding: Checking all immediate conflicts restricted to an unfolding") {}