async-wait async-waitany async-waitall
energy-link energy-ptask
io io-file-remote io-storage-raw
- plugin-hostload mutex)
+ platform-properties plugin-hostload mutex)
add_executable (s4u-${example} ${example}/s4u-${example}.cpp)
target_link_libraries(s4u-${example} simgrid)
set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actions-storage/s4u-actions-storage_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actor-priority/s4u-actor-priority_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/actor-yield/s4u-actor-yield_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
- ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/s4u-platform-properties_d.xml
PARENT_SCOPE)
set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p0.txt
${CMAKE_CURRENT_SOURCE_DIR}/actions-comm/s4u-actions-comm-split-p1.txt
async-wait async-waitall async-waitany
dht-chord
energy-link energy-ptask
- plugin-hostload mutex
+ platform-properties plugin-hostload mutex
io io-file-remote io-storage-raw)
ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --cd ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example} s4u-${example}.tesh)
endforeach()
--- /dev/null
+/* Copyright (c) 2017. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <simgrid/s4u.hpp>
+#include <string>
+
+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<std::string, std::string>* props = thehost->getProperties();
+ 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());
+
+ XBT_INFO("== Try to get a host property that does not exist");
+ value = thehost->getProperty(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);
+ 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");
+
+ /* Test if we have changed the value */
+ value = thehost->getProperty(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");
+}
+
+static int alice(int argc, char* argv[])
+{
+ /* Dump what we have on the current host */
+ test_host("host1");
+ return 0;
+}
+
+static int carole(int argc, char* argv[])
+{
+ /* Dump what we have on a remote host */
+ simgrid::s4u::this_actor::sleep_for(1); // Wait for alice to be done with its experiment
+ test_host("host1");
+ return 0;
+}
+
+static int david(int argc, char* argv[])
+{
+ /* Dump what we have on a remote host */
+ simgrid::s4u::this_actor::sleep_for(2); // Wait for alice and carole to be done with its experiment
+ test_host("node-0.acme.org");
+ return 0;
+}
+
+static int bob(int argc, char* argv[])
+{
+ /* this host also tests the properties of the AS*/
+ simgrid::s4u::NetZone* root = simgrid::s4u::Engine::getInstance()->getNetRoot();
+ 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"));
+
+ /* Get the property list of current bob process */
+ std::map<std::string, std::string>* props = simgrid::s4u::Actor::self()->getProperties();
+ const char* noexist = "UnknownProcessProp";
+ XBT_ATTRIB_UNUSED const char* value;
+
+ XBT_INFO("== Print the properties of the actor");
+ for (const auto& kv : *props)
+ XBT_INFO(" Actor property: %s -> %s", kv.first.c_str(), kv.second.c_str());
+
+ XBT_INFO("== Try to get an actor property that does not exist");
+
+ value = simgrid::s4u::Actor::self()->getProperty(noexist);
+ xbt_assert(not value, "The property is defined (it shouldnt)");
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine e(&argc, argv);
+ e.loadPlatform(argv[1]);
+
+ e.registerFunction("alice", alice);
+ e.registerFunction("bob", bob);
+ e.registerFunction("carole", carole);
+ e.registerFunction("david", david);
+
+ size_t totalHosts = sg_host_count();
+
+ XBT_INFO("There are %zu hosts in the environment", totalHosts);
+ simgrid::s4u::Host** hosts = sg_host_list();
+ for (unsigned int i = 0; i < totalHosts; i++)
+ XBT_INFO("Host '%s' runs at %.0f flops/s", hosts[i]->getCname(), hosts[i]->getSpeed());
+
+ e.loadDeployment(argv[2]);
+ e.run();
+
+ return 0;
+}
--- /dev/null
+#! ./tesh
+
+p Testing a S4U application with properties in the XML for Hosts, Links and Actors
+
+! output sort 19
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-properties$EXEEXT ${srcdir:=.}/prop.xml ${srcdir:=.}/../s4u/platform-properties/s4u-platform-properties_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:maestro@) There are 7 hosts in the environment
+> [ 0.000000] (0:maestro@) Host 'host1' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'host2' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'node-0.acme.org' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'node-1.acme.org' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'node-2.acme.org' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'node-3.acme.org' runs at 1000000000 flops/s
+> [ 0.000000] (0:maestro@) Host 'node-4.acme.org' runs at 1000000000 flops/s
+> [ 0.000000] (2:bob@host1) == Print the properties of the 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
+> [ 0.000000] (2:bob@host1) == Print the properties of the actor
+> [ 0.000000] (2:bob@host1) Actor property: SomeProp -> SomeValue
+> [ 0.000000] (2:bob@host1) == Try to get an actor property that does not exist
+> [ 0.000000] (1:alice@host1) == Print the properties of the host 'host1'
+> [ 0.000000] (1:alice@host1) Host property: 'Hdd' -> '180'
+> [ 0.000000] (1:alice@host1) Host property: 'mem' -> '4'
+> [ 0.000000] (1:alice@host1) == Try to get a host property that does not exist
+> [ 0.000000] (1:alice@host1) == Try to get a host property that does exist
+> [ 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
+> [ 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'
+> [ 1.000000] (3:carole@host2) == Try to get a host property that does not exist
+> [ 1.000000] (3:carole@host2) == Try to get a host property that does exist
+> [ 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
+> [ 2.000000] (4:david@host2) == Print the properties of the host 'node-0.acme.org'
+> [ 2.000000] (4:david@host2) Host property: 'Hdd' -> '180'
+> [ 2.000000] (4:david@host2) Host property: 'bla' -> 'acme cluster'
+> [ 2.000000] (4:david@host2) Host property: 'mem' -> '42'
+> [ 2.000000] (4:david@host2) == Try to get a host property that does not exist
+> [ 2.000000] (4:david@host2) == Try to get a host property that does exist
+> [ 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