Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5acb60c30b3a3c6b10de2703484849e9d879bff5
[simgrid.git] / teshsuite / simdag / is-router / is-router.cpp
1 /* Copyright (c) 2008-2020. 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 "simgrid/kernel/routing/NetPoint.hpp"
7 #include "simgrid/s4u/Engine.hpp"
8 #include "simgrid/s4u/Host.hpp"
9 #include "simgrid/simdag.h"
10
11 #include <algorithm>
12 #include <cstdio>
13
14 int main(int argc, char **argv)
15 {
16   SD_init(&argc, argv);
17   SD_create_environment(argv[1]);
18
19   std::vector<sg_host_t> hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts();
20   std::printf("Host count: %zu, link number: %d\n", hosts.size(), sg_link_count());
21
22   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
23       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
24   std::sort(netpoints.begin(), netpoints.end(),
25             [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
26               return a->get_name() < b->get_name();
27             });
28
29   for (const auto& host : hosts) {
30     const simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
31     const char *type = "buggy";
32     if (nc->is_router())
33       type = "router";
34     if (nc->is_netzone())
35       type = "netzone";
36     if (nc->is_host())
37       type = "host";
38     std::printf("   - Seen: \"%s\". Type: %s\n", host->get_cname(), type);
39   }
40
41   std::printf("NetCards count: %zu\n", netpoints.size());
42   for (auto const& nc : netpoints) {
43     const char* type;
44     if (nc->is_router())
45       type = "router";
46     else if (nc->is_netzone())
47       type = "netzone";
48     else if (nc->is_host())
49       type = "host";
50     else
51       type = "buggy";
52     std::printf("   - Seen: \"%s\". Type: %s\n", nc->get_cname(), type);
53   }
54   return 0;
55 }