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/FatTreeZone.hpp"
9 #include "simgrid/kernel/routing/NetPoint.hpp"
10 #include "simgrid/s4u/Engine.hpp"
11 #include "simgrid/s4u/Host.hpp"
12 #include "simgrid/s4u/NetZone.hpp"
17 explicit EngineWrapper(std::string name) : argv(&name[0]), e(&argc, &argv) {}
20 simgrid::s4u::Engine e;
23 std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
24 create_host(simgrid::s4u::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id)
26 const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
27 return std::make_pair(host->get_netpoint(), nullptr);
31 TEST_CASE("kernel::routing::FatTreeZone: Creating Zone", "")
33 using namespace simgrid::s4u;
34 EngineWrapper e("test");
35 ClusterCallbacks callbacks(create_host);
36 REQUIRE(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9, 10,
37 simgrid::s4u::Link::SharingPolicy::SHARED));
40 TEST_CASE("kernel::routing::FatTreeZone: Invalid params", "")
42 using namespace simgrid::s4u;
43 EngineWrapper e("test");
44 ClusterCallbacks callbacks(create_host);
48 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {0, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9,
49 10, simgrid::s4u::Link::SharingPolicy::SHARED),
50 std::invalid_argument);
53 SECTION("Invalid down links")
55 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4}, {1, 2}, {1, 2}}, callbacks, 1e9, 10,
56 simgrid::s4u::Link::SharingPolicy::SHARED),
57 std::invalid_argument);
60 SECTION("Invalid up links")
62 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1}, {1, 2}}, callbacks, 1e9, 10,
63 simgrid::s4u::Link::SharingPolicy::SHARED),
64 std::invalid_argument);
67 SECTION("Invalid link count")
69 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1}}, callbacks, 1e9, 10,
70 simgrid::s4u::Link::SharingPolicy::SHARED),
71 std::invalid_argument);
74 SECTION("Down links with zeroes")
76 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 0}, {1, 2}, {1, 2}}, callbacks, 1e9,
77 10, simgrid::s4u::Link::SharingPolicy::SHARED),
78 std::invalid_argument);
81 SECTION("Up links with zeroes")
83 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {0, 2}, {1, 2}}, callbacks, 1e9,
84 10, simgrid::s4u::Link::SharingPolicy::SHARED),
85 std::invalid_argument);
88 SECTION("Link count with zeroes")
90 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 0}}, callbacks, 1e9,
91 10, simgrid::s4u::Link::SharingPolicy::SHARED),
92 std::invalid_argument);
95 SECTION("0 bandwidth")
97 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 0, 10,
98 simgrid::s4u::Link::SharingPolicy::SHARED),
99 std::invalid_argument);
102 SECTION("Negative latency")
104 REQUIRE_THROWS_AS(create_fatTree_zone("test", e.e.get_netzone_root(), {2, {4, 4}, {1, 2}, {1, 2}}, callbacks, 1e9,
105 -10, simgrid::s4u::Link::SharingPolicy::SHARED),
106 std::invalid_argument);