#include <string>
{
std::map<std::string, std::string>* props = thehost->
getProperties();
const char* noexist = "Unknown";
const char* exist = "Hdd";
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");
xbt_assert(not value,
"The key exists (it's not supposed to)");
XBT_INFO(
"== Try to get a host property that does 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");
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);
}
static int alice(
int argc,
char*
argv[])
{
test_host("host1");
return 0;
}
static int carole(
int argc,
char*
argv[])
{
test_host("host1");
return 0;
}
static int david(
int argc,
char*
argv[])
{
test_host("node-0.acme.org");
return 0;
}
{
XBT_INFO(
"== Print the properties of the zone");
const char* noexist = "UnknownProcessProp";
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");
xbt_assert(not value,
"The property is defined (it shouldnt)");
return 0;
}
int main(
int argc,
char* argv[])
{
e.loadPlatform(argv[1]);
e.registerFunction("alice", alice);
e.registerFunction("bob", bob);
e.registerFunction("carole", carole);
e.registerFunction("david", david);
XBT_INFO(
"There are %zu hosts in the environment", totalHosts);
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;
}