X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f365dfb058131f5436c5cd47612c9cf5ebe49993..30dcd207e3a68158b0af4ed3d6fccf620cfe2966:/src/kernel/routing/TorusZone_test.cpp diff --git a/src/kernel/routing/TorusZone_test.cpp b/src/kernel/routing/TorusZone_test.cpp index 29d20c4109..cdaf1981d1 100644 --- a/src/kernel/routing/TorusZone_test.cpp +++ b/src/kernel/routing/TorusZone_test.cpp @@ -5,83 +5,45 @@ #include "catch.hpp" -#include "simgrid/kernel/routing/NetPoint.hpp" +#include "NetZone_test.hpp" // CreateHost callback #include "simgrid/kernel/routing/TorusZone.hpp" #include "simgrid/s4u/Engine.hpp" -#include "simgrid/s4u/Host.hpp" -#include "simgrid/s4u/NetZone.hpp" -#include "src/surf/network_interface.hpp" -#include "src/surf/surf_interface.hpp" // create models -#include "src/surf/xml/platf_private.hpp" // RouteCreationArgs and friends - -namespace { -class EngineWrapper { - int argc = 1; - char* argv; - -public: - simgrid::s4u::Engine e; - explicit EngineWrapper(std::string name) : argv(&name[0]), e(&argc, &argv) - { - simgrid::s4u::create_full_zone("root"); - surf_network_model_init_LegrandVelho(); - surf_cpu_model_init_Cas01(); - } -}; - -std::pair -create_host(simgrid::s4u::NetZone* zone, const std::vector& coord, int id) -{ - simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal(); - return std::make_pair(host->get_netpoint(), nullptr); -} -} // namespace TEST_CASE("kernel::routing::TorusZone: Creating Zone", "") { - using namespace simgrid::s4u; - EngineWrapper e("test"); - auto create_host = [](NetZone* zone, const std::vector& coord, - int id) -> std::pair { - Host* host = zone->create_host(std::to_string(id), 1e9)->seal(); - return std::make_pair(host->get_netpoint(), nullptr); - }; - REQUIRE(create_torus_zone("test", e.e.get_netzone_root(), {3, 3, 3}, 1e9, 10, - simgrid::s4u::Link::SharingPolicy::SHARED, create_host)); + simgrid::s4u::Engine e("test"); + simgrid::s4u::ClusterCallbacks callbacks(CreateHost{}); + REQUIRE(create_torus_zone("test", e.get_netzone_root(), {3, 3, 3}, callbacks, 1e9, 10, + simgrid::s4u::Link::SharingPolicy::SHARED)); } TEST_CASE("kernel::routing::TorusZone: Invalid params", "") { + simgrid::s4u::Engine e("test"); + simgrid::s4u::ClusterCallbacks callbacks(CreateHost{}); + SECTION("Empty dimensions") { - using namespace simgrid::s4u; - EngineWrapper e("test"); - REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {}, 1e9, 10, - simgrid::s4u::Link::SharingPolicy::SHARED, create_host), + REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {}, callbacks, 1e9, 10, + simgrid::s4u::Link::SharingPolicy::SHARED), std::invalid_argument); } SECTION("One 0 dimension") { - using namespace simgrid::s4u; - EngineWrapper e("test"); - REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 0, 2}, 1e9, 10, - simgrid::s4u::Link::SharingPolicy::SHARED, create_host), + REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 0, 2}, callbacks, 1e9, 10, + simgrid::s4u::Link::SharingPolicy::SHARED), std::invalid_argument); } SECTION("Invalid bandwidth") { - using namespace simgrid::s4u; - EngineWrapper e("test"); - REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, 0, 10, - simgrid::s4u::Link::SharingPolicy::SHARED, create_host), + REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 0, 10, + simgrid::s4u::Link::SharingPolicy::SHARED), std::invalid_argument); } SECTION("Invalid latency") { - using namespace simgrid::s4u; - EngineWrapper e("test"); - REQUIRE_THROWS_AS(create_torus_zone("test", e.e.get_netzone_root(), {3, 2, 2}, 1e9, -10, - simgrid::s4u::Link::SharingPolicy::SHARED, create_host), + REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 1e9, -10, + simgrid::s4u::Link::SharingPolicy::SHARED), std::invalid_argument); } -} \ No newline at end of file +}