X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/453ce02e0133358ef34d58e920521b6a29fe2283..895710d49f77179d9893bc76b3e31b69fae638af:/examples/s4u/platform-properties/s4u-platform-properties.cpp diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index 62e2b84b4b..f125e9d4ab 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -5,6 +5,7 @@ // TODO: also test the properties attached to links +#include #include #include @@ -13,14 +14,19 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Property test"); static void test_host(std::string hostname) { simgrid::s4u::Host* thehost = simgrid::s4u::Host::by_name(hostname); - std::map* props = thehost->getProperties(); + std::unordered_map* props = thehost->get_properties(); const char* noexist = "Unknown"; const char* exist = "Hdd"; const char* value; XBT_INFO("== Print the properties of the host '%s'", hostname.c_str()); - for (const auto& kv : *props) - XBT_INFO(" Host property: '%s' -> '%s'", kv.first.c_str(), kv.second.c_str()); + // Sort the properties before displaying them, so that the tests are perfectly reproducible + std::vector keys; + for (auto const& kv : *props) + 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("== Try to get a host property that does not exist"); value = thehost->get_property(noexist); @@ -78,7 +84,7 @@ static int bob(int argc, char* argv[]) XBT_INFO(" Zone property: author -> %s", root->get_property("author")); /* Get the property list of current bob process */ - std::map* props = simgrid::s4u::Actor::self()->get_properties(); + std::unordered_map* props = simgrid::s4u::Actor::self()->get_properties(); const char* noexist = "UnknownProcessProp"; XBT_ATTRIB_UNUSED const char* value;