From 2911b8122231fb6dcda07110d191b4b16dd42e36 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 24 Jul 2019 15:19:37 +0200 Subject: [PATCH 1/1] example s4u-platform-properties: test thehost->get_englobing_zone and diplay its properties --- examples/platforms/prop.xml | 1 + .../s4u-platform-properties.cpp | 18 ++++++++++++++---- .../s4u-platform-properties.tesh | 10 +++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/platforms/prop.xml b/examples/platforms/prop.xml index 6a0ac5cf18..b476efb8d6 100644 --- a/examples/platforms/prop.xml +++ b/examples/platforms/prop.xml @@ -26,6 +26,7 @@ + diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index e85410a35a..12e793d020 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Property test"); static void test_host(const std::string& hostname) { simgrid::s4u::Host* thehost = simgrid::s4u::Host::by_name(hostname); - const std::unordered_map* props = thehost->get_properties(); + const std::unordered_map* hostprops = thehost->get_properties(); const char* noexist = "Unknown"; const char* exist = "Hdd"; const char* value; @@ -22,11 +22,11 @@ static void test_host(const std::string& hostname) XBT_INFO("== Print the properties of the host '%s'", hostname.c_str()); // Sort the properties before displaying them, so that the tests are perfectly reproducible std::vector keys; - for (auto const& kv : *props) + for (auto const& kv : *hostprops) keys.push_back(kv.first); std::sort(keys.begin(), keys.end()); for (std::string key : keys) - XBT_INFO(" Host property: '%s' -> '%s'", key.c_str(), props->at(key).c_str()); + XBT_INFO(" Host property: '%s' -> '%s'", key.c_str(), hostprops->at(key).c_str()); XBT_INFO("== Try to get a host property that does not exist"); value = thehost->get_property(noexist); @@ -49,6 +49,16 @@ static void test_host(const std::string& hostname) /* Restore the value for the next test */ thehost->set_property(exist, "180"); + + auto thezone = thehost->get_englobing_zone(); + XBT_INFO("== Print the properties of the zone '%s' that contains '%s'", thezone->get_cname(), hostname.c_str()); + const std::unordered_map* zoneprops = thezone->get_properties(); + keys.clear(); + for (auto const& kv : *zoneprops) + keys.push_back(kv.first); + std::sort(keys.begin(), keys.end()); + for (std::string key : keys) + XBT_INFO(" Zone property: '%s' -> '%s'", key.c_str(), zoneprops->at(key).c_str()); } static void alice(std::vector /*args*/) @@ -75,7 +85,7 @@ static void bob(std::vector /*args*/) { /* this host also tests the properties of the AS*/ simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root(); - XBT_INFO("== Print the properties of the zone"); + XBT_INFO("== Print the properties of the root zone"); XBT_INFO(" Zone property: filename -> %s", root->get_property("filename")); XBT_INFO(" Zone property: date -> %s", root->get_property("date")); XBT_INFO(" Zone property: author -> %s", root->get_property("author")); diff --git a/examples/s4u/platform-properties/s4u-platform-properties.tesh b/examples/s4u/platform-properties/s4u-platform-properties.tesh index 9a93d119db..f9a14b8093 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.tesh +++ b/examples/s4u/platform-properties/s4u-platform-properties.tesh @@ -12,7 +12,7 @@ $ ${bindir:=.}/s4u-platform-properties ${platfdir}/prop.xml s4u-platform-propert > [ 0.000000] (0:maestro@) Host 'node-2.simgrid.org' runs at 1000000000 flops/s > [ 0.000000] (0:maestro@) Host 'node-3.simgrid.org' runs at 1000000000 flops/s > [ 0.000000] (0:maestro@) Host 'node-4.simgrid.org' runs at 1000000000 flops/s -> [ 0.000000] (2:bob@host1) == Print the properties of the zone +> [ 0.000000] (2:bob@host1) == Print the properties of the root zone > [ 0.000000] (2:bob@host1) Zone property: filename -> prop.xml > [ 0.000000] (2:bob@host1) Zone property: date -> 31-08-12 > [ 0.000000] (2:bob@host1) Zone property: author -> pnavarro @@ -27,6 +27,8 @@ $ ${bindir:=.}/s4u-platform-properties ${platfdir}/prop.xml s4u-platform-propert > [ 0.000000] (1:alice@host1) Property: Hdd old value: 180 > [ 0.000000] (1:alice@host1) == Trying to modify a host property > [ 0.000000] (1:alice@host1) Property: Hdd old value: 250 +> [ 0.000000] (1:alice@host1) == Print the properties of the zone 'AS4' that contains 'host1' +> [ 0.000000] (1:alice@host1) Zone property: 'bla' -> 'bli' > [ 1.000000] (3:carole@host2) == Print the properties of the host 'host1' > [ 1.000000] (3:carole@host2) Host property: 'Hdd' -> '180' > [ 1.000000] (3:carole@host2) Host property: 'mem' -> '4' @@ -35,6 +37,8 @@ $ ${bindir:=.}/s4u-platform-properties ${platfdir}/prop.xml s4u-platform-propert > [ 1.000000] (3:carole@host2) Property: Hdd old value: 180 > [ 1.000000] (3:carole@host2) == Trying to modify a host property > [ 1.000000] (3:carole@host2) Property: Hdd old value: 250 +> [ 1.000000] (3:carole@host2) == Print the properties of the zone 'AS4' that contains 'host1' +> [ 1.000000] (3:carole@host2) Zone property: 'bla' -> 'bli' > [ 2.000000] (4:david@host2) == Print the properties of the host 'node-0.simgrid.org' > [ 2.000000] (4:david@host2) Host property: 'Hdd' -> '180' > [ 2.000000] (4:david@host2) Host property: 'bla' -> 'acme cluster' @@ -44,3 +48,7 @@ $ ${bindir:=.}/s4u-platform-properties ${platfdir}/prop.xml s4u-platform-propert > [ 2.000000] (4:david@host2) Property: Hdd old value: 180 > [ 2.000000] (4:david@host2) == Trying to modify a host property > [ 2.000000] (4:david@host2) Property: Hdd old value: 250 +> [ 2.000000] (4:david@host2) == Print the properties of the zone 'acme' that contains 'node-0.simgrid.org' +> [ 2.000000] (4:david@host2) Zone property: 'Hdd' -> '180' +> [ 2.000000] (4:david@host2) Zone property: 'bla' -> 'acme cluster' +> [ 2.000000] (4:david@host2) Zone property: 'mem' -> '42' -- 2.20.1