1 /* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved. */
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. */
8 #include "simgrid/kernel/routing/NetPoint.hpp"
9 #include "simgrid/kernel/routing/TorusZone.hpp"
10 #include "simgrid/s4u/Engine.hpp"
11 #include "simgrid/s4u/Host.hpp"
12 #include "simgrid/s4u/NetZone.hpp"
15 std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
16 create_host(simgrid::s4u::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id)
18 const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
19 return std::make_pair(host->get_netpoint(), nullptr);
23 TEST_CASE("kernel::routing::TorusZone: Creating Zone", "")
25 simgrid::s4u::Engine e("test");
26 simgrid::s4u::ClusterCallbacks callbacks(create_host);
27 REQUIRE(create_torus_zone("test", e.get_netzone_root(), {3, 3, 3}, callbacks, 1e9, 10,
28 simgrid::s4u::Link::SharingPolicy::SHARED));
31 TEST_CASE("kernel::routing::TorusZone: Invalid params", "")
33 simgrid::s4u::Engine e("test");
34 simgrid::s4u::ClusterCallbacks callbacks(create_host);
36 SECTION("Empty dimensions")
38 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {}, callbacks, 1e9, 10,
39 simgrid::s4u::Link::SharingPolicy::SHARED),
40 std::invalid_argument);
42 SECTION("One 0 dimension")
44 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 0, 2}, callbacks, 1e9, 10,
45 simgrid::s4u::Link::SharingPolicy::SHARED),
46 std::invalid_argument);
48 SECTION("Invalid bandwidth")
50 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 0, 10,
51 simgrid::s4u::Link::SharingPolicy::SHARED),
52 std::invalid_argument);
54 SECTION("Invalid latency")
56 REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 1e9, -10,
57 simgrid::s4u::Link::SharingPolicy::SHARED),
58 std::invalid_argument);