Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2023.
[simgrid.git] / teshsuite / s4u / basic-parsing-test / basic-parsing-test.cpp
index 00951ca..b69c457 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2021. The SimGrid Team.
+/* Copyright (c) 2008-2023. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(basic_parsing_test, "[usage] basic-parsing-test <pl
 
 namespace sg4 = simgrid::s4u;
 
-static void test_one_link(const std::vector<sg4::Host*> hosts)
+static void test_one_link(const std::vector<sg4::Host*>& hosts)
 {
   const sg4::Host* h1 = hosts[0];
   const sg4::Host* h2 = hosts[1];
@@ -23,17 +23,16 @@ static void test_one_link(const std::vector<sg4::Host*> hosts)
   h1->route_to(h2, route, &latency);
   XBT_INFO("Route size %zu", route.size());
 
-  for (auto link: route) {
+  for (auto const* link : route) {
     double bandwidth = link->get_bandwidth();
     XBT_INFO("  Link %s: latency = %f, bandwidth = %f", link->get_cname(), link->get_latency(), bandwidth);
     if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
       min_bandwidth = bandwidth;
-
   }
   XBT_INFO("Route latency = %f, route bandwidth = %f", latency, min_bandwidth);
 }
 
-static void test_full_link(const std::vector<sg4::Host*> hosts)
+static void test_full_link(const std::vector<sg4::Host*>& hosts)
 {
   size_t list_size = hosts.size();
   for (size_t i = 0; i < list_size; i++) {
@@ -47,12 +46,11 @@ static void test_full_link(const std::vector<sg4::Host*> hosts)
       h1->route_to(h2, route, &latency);
       XBT_INFO("  Route size %zu", route.size());
 
-      for (auto link: route) {
+      for (auto const* link : route) {
         double bandwidth = link->get_bandwidth();
         XBT_INFO("  Link %s: latency = %f, bandwidth = %f", link->get_cname(), link->get_latency(), bandwidth);
         if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
           min_bandwidth = bandwidth;
-
       }
       XBT_INFO("  Route latency = %f, route bandwidth = %f", latency, min_bandwidth);
     }
@@ -61,20 +59,21 @@ static void test_full_link(const std::vector<sg4::Host*> hosts)
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine e(&argc, argv);
+  sg4::Engine e(&argc, argv);
 
   /* creation of the environment */
   e.load_platform(argv[1]);
+  e.seal_platform();
   XBT_INFO("Workstation number: %zu, link number: %zu", e.get_host_count(), e.get_link_count());
 
-  std::vector<simgrid::s4u::Host*> hosts = e.get_all_hosts();
+  std::vector<sg4::Host*> hosts = e.get_all_hosts();
   if (argc >= 3) {
-    if (!strcmp(argv[2], "ONE_LINK"))
+    if (strcmp(argv[2], "ONE_LINK") == 0)
       test_one_link(hosts);
-    if (!strcmp(argv[2], "FULL_LINK"))
+    if (strcmp(argv[2], "FULL_LINK") == 0)
       test_full_link(hosts);
-    if (!strcmp(argv[2], "PROP"))
-      XBT_INFO("SG_TEST_mem: %s", sg4::Host::by_name("host1")->get_property("SG_TEST_mem"));
+    if (strcmp(argv[2], "PROP") == 0)
+      XBT_INFO("SG_TEST_mem: %s", e.host_by_name("host1")->get_property("SG_TEST_mem"));
   }
 
   return 0;