X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/aba4495e3f8bca80611d2cdc84c3bb75ccd32f74..c6683b41cf9ecda70c1d4d75d1effc61903a894f:/src/mc/explo/odpor/Execution_test.cpp diff --git a/src/mc/explo/odpor/Execution_test.cpp b/src/mc/explo/odpor/Execution_test.cpp index e2b1a49280..364d9a0c7c 100644 --- a/src/mc/explo/odpor/Execution_test.cpp +++ b/src/mc/explo/odpor/Execution_test.cpp @@ -592,6 +592,79 @@ TEST_CASE("simgrid::mc::odpor::Execution: Initials Test") } } +TEST_CASE("simgrid::mc::odpor::Execution: SDPOR Backtracking Simulation") +{ + // This test case assumes that each detected race is detected to also + // be reversible. For each reversible + const auto e0 = std::make_shared(Transition::Type::UNKNOWN, 1); + const auto e1 = std::make_shared(Transition::Type::UNKNOWN, 1); + const auto e2 = std::make_shared(Transition::Type::UNKNOWN, 3); + const auto e3 = std::make_shared(Transition::Type::UNKNOWN, 4); + const auto e4 = std::make_shared(Transition::Type::UNKNOWN, 4); + const auto e5 = std::make_shared(Transition::Type::UNKNOWN, 2); + const auto e6 = std::make_shared(Transition::Type::UNKNOWN, 3); + const auto e7 = std::make_shared(Transition::Type::UNKNOWN, 1); + + Execution execution; + + execution.push_transition(e0); + REQUIRE(execution.get_racing_events_of(0) == std::unordered_set{}); + + execution.push_transition(e1); + REQUIRE(execution.get_racing_events_of(1) == std::unordered_set{}); + + // Actor 3, since it starts the extension from event 1, clearly is an initial from there + execution.push_transition(e2); + REQUIRE(execution.get_racing_events_of(2) == std::unordered_set{1}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{}) == std::unordered_set{3}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{4, 5}) == + std::unordered_set{3}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{3}) == std::unordered_set{}); + + // e1 and e3 are in an reversible race. Actor 4 is not hindered from being moved to + // the front since e2 is independent with e3; hence, it is an initial + execution.push_transition(e3); + REQUIRE(execution.get_racing_events_of(3) == std::unordered_set{1}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{}) == std::unordered_set{4}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{3, 5}) == + std::unordered_set{4}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{4}) == std::unordered_set{}); + + // e4 is not in a race since e3 is run by the same actor and occurs before e4 + execution.push_transition(e4); + REQUIRE(execution.get_racing_events_of(4) == std::unordered_set{}); + + // e5 is independent with everything between e1 and e5, and `proc(e5) == 2` + execution.push_transition(e5); + REQUIRE(execution.get_racing_events_of(5) == std::unordered_set{1}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{}) == std::unordered_set{2}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{4, 5}) == + std::unordered_set{2}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{2}) == std::unordered_set{}); + + // Event 6 has two races: one with event 4 and one with event 5. In the latter race, actor 3 follows + // immediately after and so is evidently a source set actor; in the former race, only actor 2 can + // be brought to the front of the queue + execution.push_transition(e6); + REQUIRE(execution.get_racing_events_of(6) == std::unordered_set{4, 5}); + CHECK(execution.get_missing_source_set_actors_from(4, std::unordered_set{}) == std::unordered_set{2}); + CHECK(execution.get_missing_source_set_actors_from(4, std::unordered_set{6, 7}) == + std::unordered_set{2}); + CHECK(execution.get_missing_source_set_actors_from(4, std::unordered_set{2}) == std::unordered_set{}); + CHECK(execution.get_missing_source_set_actors_from(5, std::unordered_set{}) == std::unordered_set{3}); + CHECK(execution.get_missing_source_set_actors_from(5, std::unordered_set{6, 7}) == + std::unordered_set{3}); + CHECK(execution.get_missing_source_set_actors_from(5, std::unordered_set{3}) == std::unordered_set{}); + + // Finally, event e7 races with e6 and `proc(e7) = 1` is brought forward + execution.push_transition(e7); + REQUIRE(execution.get_racing_events_of(7) == std::unordered_set{6}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{}) == std::unordered_set{1}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{4, 5}) == + std::unordered_set{1}); + CHECK(execution.get_missing_source_set_actors_from(1, std::unordered_set{1}) == std::unordered_set{}); +} + TEST_CASE("simgrid::mc::odpor::Execution: ODPOR Smallest Sequence Tests") { const auto a0 = std::make_shared(Transition::Type::UNKNOWN, 2);