From b7f1c354386134784f90d96dab71b2b5a3f45c23 Mon Sep 17 00:00:00 2001 From: Maxwell Pirtle Date: Tue, 7 Mar 2023 14:05:01 +0100 Subject: [PATCH] Add asserts for Configuration vs EventSet This commit adds two asserts to ensure that traversing a configuration is equivalent to traversing the events of that configuration. That is, the assertions check that a configuration can effectively be treated as a set of events when it comes to traversal of maximal sets and computing a topological ordering --- src/mc/explo/udpor/Configuration_test.cpp | 33 +++++++++++++++++++ .../explo/udpor/maximal_subsets_iterator.hpp | 7 ++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/mc/explo/udpor/Configuration_test.cpp b/src/mc/explo/udpor/Configuration_test.cpp index aadcbd1241..af975fc467 100644 --- a/src/mc/explo/udpor/Configuration_test.cpp +++ b/src/mc/explo/udpor/Configuration_test.cpp @@ -386,6 +386,13 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli REQUIRE(events_seen == ordered_event_set); } } + + SECTION("Test that the topological ordering is equivalent to that of the configuration's events") + { + REQUIRE(C.get_topologically_sorted_events() == C.get_events().get_topological_ordering()); + REQUIRE(C.get_topologically_sorted_events_of_reverse_graph() == + C.get_events().get_topological_ordering_of_reverse_graph()); + } } TEST_CASE("simgrid::mc::udpor::maximal_subsets_iterator: Basic Testing of Maximal Subsets") @@ -564,4 +571,30 @@ TEST_CASE("simgrid::mc::udpor::maximal_subsets_iterator: Stress Test for Maximal REQUIRE((*first).is_maximal()); } } + + SECTION("Test that the maximal set ordering is equivalent to that of the configuration's events") + { + maximal_subsets_iterator first_config(C); + maximal_subsets_iterator first_events(C.get_events()); + maximal_subsets_iterator last; + + // Make sure we actually have something to iterate over + REQUIRE(first_config != last); + REQUIRE(first_config == first_events); + REQUIRE(first_events != last); + + for (; first_config != last; ++first_config, ++first_events) { + // first_events and first_config should always be at the same location + REQUIRE(first_events != last); + const auto& first_config_set = *first_config; + const auto& first_events_set = *first_events; + + REQUIRE(first_config_set.size() <= C.get_events().size()); + REQUIRE(first_config_set.is_maximal()); + REQUIRE(first_events_set == first_config_set); + } + + // Iteration with events directly should now also be finished + REQUIRE(first_events == last); + } } \ No newline at end of file diff --git a/src/mc/explo/udpor/maximal_subsets_iterator.hpp b/src/mc/explo/udpor/maximal_subsets_iterator.hpp index 08cd90733e..2be3497aea 100644 --- a/src/mc/explo/udpor/maximal_subsets_iterator.hpp +++ b/src/mc/explo/udpor/maximal_subsets_iterator.hpp @@ -39,10 +39,9 @@ public: using topological_order_position = std::vector::const_iterator; maximal_subsets_iterator() = default; - explicit maximal_subsets_iterator(const Configuration& config) - : maximal_subsets_iterator(config.get_events(), std::nullopt) - { - } + explicit maximal_subsets_iterator(const Configuration& config) : maximal_subsets_iterator(config.get_events()) {} + explicit maximal_subsets_iterator(const EventSet& events) : maximal_subsets_iterator(events, std::nullopt) {} + maximal_subsets_iterator(const Configuration& config, std::optional filter) : maximal_subsets_iterator(config.get_events(), filter) { -- 2.20.1