Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill EngineWrapper hack and reduce code duplication.
[simgrid.git] / src / kernel / routing / DragonflyZone_test.cpp
1 /* Copyright (c) 2017-2021. The SimGrid Team. All rights reserved.               */
2
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. */
5
6 #include "catch.hpp"
7
8 #include "simgrid/kernel/routing/DragonflyZone.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"
13
14 namespace {
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)
17 {
18   const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
19   return std::make_pair(host->get_netpoint(), nullptr);
20 }
21 } // namespace
22
23 TEST_CASE("kernel::routing::DragonflyZone: Creating Zone", "")
24 {
25   simgrid::s4u::Engine e("test");
26   simgrid::s4u::ClusterCallbacks callbacks(create_host);
27   REQUIRE(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9, 10,
28                                 simgrid::s4u::Link::SharingPolicy::SHARED));
29 }
30
31 TEST_CASE("kernel::routing::DragonflyZone: Invalid params", "")
32 {
33   simgrid::s4u::Engine e("test");
34   simgrid::s4u::ClusterCallbacks callbacks(create_host);
35
36   SECTION("0 nodes")
37   {
38     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 0}, callbacks, 1e9,
39                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
40                       std::invalid_argument);
41   }
42
43   SECTION("0 groups")
44   {
45     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{0, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
46                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
47                       std::invalid_argument);
48   }
49   SECTION("0 groups links")
50   {
51     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 0}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
52                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
53                       std::invalid_argument);
54   }
55
56   SECTION("0 chassis")
57   {
58     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {0, 3}, {5, 1}, 2}, callbacks, 1e9,
59                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
60                       std::invalid_argument);
61   }
62
63   SECTION("0 chassis links")
64   {
65     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 0}, {5, 1}, 2}, callbacks, 1e9,
66                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
67                       std::invalid_argument);
68   }
69
70   SECTION("0 routers")
71   {
72     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {0, 1}, 2}, callbacks, 1e9,
73                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
74                       std::invalid_argument);
75   }
76
77   SECTION("0 routers links")
78   {
79     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 0}, 2}, callbacks, 1e9,
80                                             10, simgrid::s4u::Link::SharingPolicy::SHARED),
81                       std::invalid_argument);
82   }
83
84   SECTION("0 bandwidth")
85   {
86     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 0, 10,
87                                             simgrid::s4u::Link::SharingPolicy::SHARED),
88                       std::invalid_argument);
89   }
90
91   SECTION("Negative latency")
92   {
93     REQUIRE_THROWS_AS(create_dragonfly_zone("test", e.get_netzone_root(), {{3, 4}, {4, 3}, {5, 1}, 2}, callbacks, 1e9,
94                                             -10, simgrid::s4u::Link::SharingPolicy::SHARED),
95                       std::invalid_argument);
96   }
97 }