Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
523080ccba6219f77c2b45e4687c39c169679eaf
[simgrid.git] / teshsuite / simdag / is-router / is-router.cpp
1 /* Copyright (c) 2008-2017. 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/s4u/Engine.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "simgrid/simdag.h"
9 #include "src/kernel/routing/NetPoint.hpp"
10 #include <stdio.h>
11
12 int main(int argc, char **argv)
13 {
14   SD_init(&argc, argv);
15   SD_create_environment(argv[1]);
16
17   xbt_dynar_t hosts = sg_hosts_as_dynar();
18   std::printf("Host count: %zu, link number: %d\n", sg_host_count(), sg_link_count());
19
20   std::vector<simgrid::kernel::routing::NetPoint*> netcardList;
21   simgrid::s4u::Engine::instance()->netpointList(&netcardList);
22   std::sort(netcardList.begin(), netcardList.end(),
23             [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
24               return a->name() < b->name();
25             });
26
27   int it;
28   sg_host_t host;
29   xbt_dynar_foreach(hosts, it, host) {
30     simgrid::kernel::routing::NetPoint* nc = host->pimpl_netpoint;
31     const char *type = "buggy";
32     if (nc->isRouter())
33       type = "router";
34     if (nc->isNetZone())
35       type = "netzone";
36     if (nc->isHost())
37       type = "host";
38     std::printf("   - Seen: \"%s\". Type: %s\n", host->cname(), type);
39   }
40   xbt_dynar_free(&hosts);
41
42   std::printf("NetCards count: %zu\n", netcardList.size());
43   for (auto nc : netcardList)
44     std::printf("   - Seen: \"%s\". Type: %s\n", nc->cname(),
45                 nc->isRouter() ? "router" : (nc->isNetZone() ? "netzone" : (nc->isHost() ? "host" : "buggy")));
46
47   return 0;
48 }