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 SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS);
43 name1 = SD_workstation_get_name(w1);
44 name2 = SD_workstation_get_name(w2);
47 /* The host properties can be retrived from all interfaces */
49 XBT_INFO("Property list for workstation %s", name1);
50 /* Get the property list of the workstation 1 */
51 props = SD_workstation_get_properties(w1);
54 /* Trying to set a new property */
55 xbt_dict_set(props, "NewProp", strdup("newValue"), xbt_free_f);
57 /* Print the properties of the workstation 1 */
58 xbt_dict_foreach(props, cursor, key, data) {
59 XBT_INFO("\tProperty: %s has value: %s", key, data);
62 /* Try to get a property that does not exist */
64 value = SD_workstation_get_property_value(w1, noexist);
66 XBT_INFO("\tProperty: %s is undefined", noexist);
68 XBT_INFO("\tProperty: %s has value: %s", noexist, value);
71 XBT_INFO("Property list for workstation %s", name2);
72 /* Get the property list of the workstation 2 */
73 props = SD_workstation_get_properties(w2);
76 /* Print the properties of the workstation 2 */
77 xbt_dict_foreach(props, cursor, key, data) {
78 XBT_INFO("\tProperty: %s on host: %s", key, data);
81 /* Modify an existing property test. First check it exists */
82 XBT_INFO("Modify an existing property");
84 value = SD_workstation_get_property_value(w2, exist);
86 XBT_INFO("\tProperty: %s is undefined", exist);
88 XBT_INFO("\tProperty: %s old value: %s", exist, value);
89 xbt_dict_set(props, exist, strdup("250"), xbt_free_f);
92 /* Test if we have changed the value */
93 value = SD_workstation_get_property_value(w2, exist);
95 XBT_INFO("\tProperty: %s is undefined", exist);
97 XBT_INFO("\tProperty: %s new value: %s", exist, value);
99 /* Test if properties are displayed by SD_workstation_dump */
100 SD_workstation_dump(w2);