Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fbfd1dcd4d127edebcb7e559bfa19e3c1a3671c0
[simgrid.git] / teshsuite / simdag / is-router / is-router.cpp
1 /* Copyright (c) 2008-2018. 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   xbt_dynar_t hosts = sg_hosts_as_dynar();
20   std::printf("Host count: %zu, link number: %d\n", sg_host_count(), sg_link_count());
21
22   std::vector<simgrid::kernel::routing::NetPoint*> netcardList;
23   simgrid::s4u::Engine::getInstance()->getNetpointList(&netcardList);
24   std::sort(netcardList.begin(), netcardList.end(),
25             [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
26               return a->get_name() < b->get_name();
27             });
28
29   int it;
30   sg_host_t host;
31   xbt_dynar_foreach(hosts, it, host) {
32     simgrid::kernel::routing::NetPoint* nc = host->pimpl_netpoint;
33     const char *type = "buggy";
34     if (nc->is_router())
35       type = "router";
36     if (nc->is_netzone())
37       type = "netzone";
38     if (nc->is_host())
39       type = "host";
40     std::printf("   - Seen: \"%s\". Type: %s\n", host->get_cname(), type);
41   }
42   xbt_dynar_free(&hosts);
43
44   std::printf("NetCards count: %zu\n", netcardList.size());
45   for (auto const& nc : netcardList)
46     std::printf("   - Seen: \"%s\". Type: %s\n", nc->get_cname(),
47                 nc->is_router() ? "router" : (nc->is_netzone() ? "netzone" : (nc->is_host() ? "host" : "buggy")));
48
49   return 0;
50 }