Logo AND Algorithmique Numérique Distribuée

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