Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / kernel / routing / DijkstraZone_test.cpp
1 /* Copyright (c) 2017-2022. 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/kernel/resource/LinkImpl.hpp"
14
15 TEST_CASE("kernel::routing::DijkstraZone: Creating Zone", "")
16 {
17   simgrid::s4u::Engine e("test");
18
19   SECTION("Regular Dijkstra") { REQUIRE(simgrid::s4u::create_dijkstra_zone("test", false)); }
20   SECTION("DijkstraCache") { REQUIRE(simgrid::s4u::create_dijkstra_zone("test", true)); }
21 }
22
23 TEST_CASE("kernel::routing::DijkstraZone: mix new routes and hosts", "")
24 {
25   simgrid::s4u::Engine e("test");
26   auto* zone = simgrid::s4u::create_dijkstra_zone("test", false);
27
28   const simgrid::s4u::Host* nic  = zone->create_host("nic", 1e9)->seal();
29   const simgrid::s4u::Link* link = zone->create_link("my_link", 1e6)->seal();
30   for (int i = 0; i < 10; i++) {
31     std::string cpu_name          = "CPU" + std::to_string(i);
32     const simgrid::s4u::Host* cpu = zone->create_host(cpu_name, 1e9)->seal();
33     REQUIRE_NOTHROW(zone->add_route(cpu->get_netpoint(), nic->get_netpoint(), nullptr, nullptr,
34                                     {simgrid::s4u::LinkInRoute(link)}, true));
35   }
36 }