5 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Simple Property example");
7 int master(int argc, char *argv[]);
8 int slave(int argc, char *argv[]);
11 int slave(int argc, char *argv[]) {
12 gras_init(&argc,argv);
14 /* Get the properties */
15 xbt_dict_t props = gras_process_properties();
16 xbt_dict_cursor_t cursor = NULL;
19 /* Print the properties of the workstation 1 */
20 xbt_dict_foreach(props,cursor,key,data) {
21 INFO2("Process property: %s has value: %s",key,data);
24 /* Try to get a property that does not exist */
25 const char *noexist="Nonexisting";
26 const char *value = gras_process_property_value(noexist);
28 INFO1("Process property: %s is undefined", noexist);
30 INFO2("Process property: %s has value: %s", noexist, value);
32 /* Modify an existing property. First check it exists */
33 INFO0("Trying to modify a process property");
34 const char *exist="otherprop";
35 value = gras_process_property_value(exist);
37 INFO1("\tProperty: %s is undefined", exist);
39 INFO2("\tProperty: %s old value: %s", exist, value);
40 xbt_dict_set(props, exist, xbt_strdup("newValue"), free);
43 /* Test if we have changed the value */
44 value = gras_process_property_value(exist);
46 INFO1("\tProperty: %s is undefined", exist);
48 INFO2("\tProperty: %s new value: %s", exist, value);
55 int master(int argc, char *argv[]) {
56 gras_init(&argc,argv);
58 /* Get the properties */
59 xbt_dict_t props = gras_os_host_properties();
60 xbt_dict_cursor_t cursor = NULL;
63 /* Print the properties of the workstation 1 */
64 xbt_dict_foreach(props,cursor,key,data) {
65 INFO2("Host property: %s has value: %s",key,data);
68 /* Try to get a property that does not exist */
69 const char *noexist="Nonexisting";
70 const char *value = gras_os_host_property_value(noexist);
71 xbt_assert2(value == NULL, "Host property: %s has value: %s", noexist, value);