X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a43ef1c628f2962dceb1994099e6a67dc292424e..12783570914b603d99b5ffff1c92517592d07e62:/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 fafbfa74ec..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,36 +14,41 @@ 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->getProperty(noexist); + value = thehost->get_property(noexist); xbt_assert(not value, "The key exists (it's not supposed to)"); XBT_INFO("== Try to get a host property that does exist"); - value = thehost->getProperty(exist); + value = thehost->get_property(exist); xbt_assert(value, "\tProperty %s is undefined (where it should)", exist); xbt_assert(!strcmp(value, "180"), "\tValue of property %s is defined to %s (where it should be 180)", exist, value); XBT_INFO(" Property: %s old value: %s", exist, value); XBT_INFO("== Trying to modify a host property"); - thehost->setProperty(exist, "250"); + thehost->set_property(exist, "250"); /* Test if we have changed the value */ - value = thehost->getProperty(exist); + value = thehost->get_property(exist); xbt_assert(value, "Property %s is undefined (where it should)", exist); xbt_assert(!strcmp(value, "250"), "Value of property %s is defined to %s (where it should be 250)", exist, value); XBT_INFO(" Property: %s old value: %s", exist, value); /* Restore the value for the next test */ - thehost->setProperty(exist, "180"); + thehost->set_property(exist, "180"); } static int alice(int argc, char* argv[]) @@ -73,12 +79,12 @@ static int bob(int argc, char* argv[]) /* 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(" Zone property: filename -> %s", root->getProperty("filename")); - XBT_INFO(" Zone property: date -> %s", root->getProperty("date")); - XBT_INFO(" Zone property: author -> %s", root->getProperty("author")); + 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")); /* 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;