Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Mix create_host and add_route during platf creation.
[simgrid.git] / src / kernel / routing / DijkstraZone_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/DijkstraZone.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 #include "src/surf/network_interface.hpp" //LinkImpl
14
15 namespace {
16 class EngineWrapper {
17   int argc = 1;
18   char* argv;
19   simgrid::s4u::Engine e;
20
21 public:
22   explicit EngineWrapper(std::string name) : argv(&name[0]), e(&argc, &argv) {}
23 };
24 } // namespace
25
26 TEST_CASE("kernel::routing::DijkstraZone: Creating Zone", "")
27 {
28   EngineWrapper e("test");
29
30   REQUIRE(simgrid::s4u::create_dijkstra_zone("test", false));
31   REQUIRE(simgrid::s4u::create_dijkstra_zone("test2", true));
32 }
33
34 TEST_CASE("kernel::routing::DijkstraZone: mix new routes and hosts", "")
35 {
36   EngineWrapper e("test");
37   auto* zone = simgrid::s4u::create_dijkstra_zone("test", false);
38
39   const simgrid::s4u::Host* nic = zone->create_host("nic", 1e9)->seal();
40   simgrid::s4u::Link* link      = zone->create_link("my_link", 1e6)->seal();
41   for (int i = 0; i < 10; i++) {
42     std::string cpu_name          = "CPU" + std::to_string(i);
43     const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
44     REQUIRE_NOTHROW(zone->add_route(cpu->get_netpoint(), nic->get_netpoint(), nullptr, nullptr,
45                                     std::vector<simgrid::s4u::Link*>{link}, true));
46   }
47 }