Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factor common code.
[simgrid.git] / src / kernel / routing / TorusZone_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 "NetZone_test.hpp" // CreateHost callback
9 #include "simgrid/kernel/routing/TorusZone.hpp"
10 #include "simgrid/s4u/Engine.hpp"
11
12 TEST_CASE("kernel::routing::TorusZone: Creating Zone", "")
13 {
14   simgrid::s4u::Engine e("test");
15   simgrid::s4u::ClusterCallbacks callbacks(CreateHost{});
16   REQUIRE(create_torus_zone("test", e.get_netzone_root(), {3, 3, 3}, callbacks, 1e9, 10,
17                             simgrid::s4u::Link::SharingPolicy::SHARED));
18 }
19
20 TEST_CASE("kernel::routing::TorusZone: Invalid params", "")
21 {
22   simgrid::s4u::Engine e("test");
23   simgrid::s4u::ClusterCallbacks callbacks(CreateHost{});
24
25   SECTION("Empty dimensions")
26   {
27     REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {}, callbacks, 1e9, 10,
28                                         simgrid::s4u::Link::SharingPolicy::SHARED),
29                       std::invalid_argument);
30   }
31   SECTION("One 0 dimension")
32   {
33     REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 0, 2}, callbacks, 1e9, 10,
34                                         simgrid::s4u::Link::SharingPolicy::SHARED),
35                       std::invalid_argument);
36   }
37   SECTION("Invalid bandwidth")
38   {
39     REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 0, 10,
40                                         simgrid::s4u::Link::SharingPolicy::SHARED),
41                       std::invalid_argument);
42   }
43   SECTION("Invalid latency")
44   {
45     REQUIRE_THROWS_AS(create_torus_zone("test", e.get_netzone_root(), {3, 2, 2}, callbacks, 1e9, -10,
46                                         simgrid::s4u::Link::SharingPolicy::SHARED),
47                       std::invalid_argument);
48   }
49 }