1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "simgrid/simdag.h"
12 #include "xbt/dynar.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test");
17 int main(int argc, char **argv)
24 xbt_dict_cursor_t cursor = NULL;
26 char noexist[] = "NoProp";
30 /* SD initialization */
33 XBT_INFO("Usage: %s platform_file", argv[0]);
34 XBT_INFO("example: %s sd_platform.xml", argv[0]);
37 SD_create_environment(argv[1]);
39 /* init of platform elements */
40 w1 = SD_workstation_get_by_name("host1");
41 w2 = SD_workstation_get_by_name("host2");
42 name1 = SD_workstation_get_name(w1);
43 name2 = SD_workstation_get_name(w2);
46 /* The host properties can be retrived from all interfaces */
48 XBT_INFO("Property list for workstation %s", name1);
49 /* Get the property list of the workstation 1 */
50 props = SD_workstation_get_properties(w1);
53 /* Trying to set a new property */
54 xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free_f);
56 /* Print the properties of the workstation 1 */
57 xbt_dict_foreach(props, cursor, key, data) {
58 XBT_INFO("\tProperty: %s has value: %s", key, data);
61 /* Try to get a property that does not exist */
63 value = SD_workstation_get_property_value(w1, noexist);
65 XBT_INFO("\tProperty: %s is undefined", noexist);
67 XBT_INFO("\tProperty: %s has value: %s", noexist, value);
70 XBT_INFO("Property list for workstation %s", name2);
71 /* Get the property list of the workstation 2 */
72 props = SD_workstation_get_properties(w2);
75 /* Print the properties of the workstation 2 */
76 xbt_dict_foreach(props, cursor, key, data) {
77 XBT_INFO("\tProperty: %s on host: %s", key, data);
80 /* Modify an existing property test. First check it exists */
81 XBT_INFO("Modify an existing property");
83 value = SD_workstation_get_property_value(w2, exist);
85 XBT_INFO("\tProperty: %s is undefined", exist);
87 XBT_INFO("\tProperty: %s old value: %s", exist, value);
88 xbt_dict_set(props, exist, strdup("250"), xbt_free_f);
91 /* Test if we have changed the value */
92 value = SD_workstation_get_property_value(w2, exist);
94 XBT_INFO("\tProperty: %s is undefined", exist);
96 XBT_INFO("\tProperty: %s new value: %s", exist, value);
98 /* Test if properties are displayed by SD_workstation_dump */
99 SD_workstation_dump(w2);