1 /* Copyright (c) 2007, 2008, 2009, 2010. 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 "simdag/simdag.h"
12 #include "xbt/dynar.h"
15 XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Property test");
17 int main(int argc, char **argv)
19 const SD_workstation_t *workstations;
25 xbt_dict_cursor_t cursor = NULL;
27 char noexist[] = "NoProp";
31 /* initialisation of SD */
34 XBT_INFO("Usage: %s platform_file", argv[0]);
35 XBT_INFO("example: %s sd_platform.xml", argv[0]);
38 SD_create_environment(argv[1]);
40 /* init of platform elements */
41 workstations = SD_workstation_get_list();
44 SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS);
45 name1 = SD_workstation_get_name(w1);
46 name2 = SD_workstation_get_name(w2);
49 /* The host properties can be retrived from all interfaces */
51 XBT_INFO("Property list for workstation %s", name1);
52 /* Get the property list of the workstation 1 */
53 props = SD_workstation_get_properties(w1);
56 /* Trying to set a new property */
57 xbt_dict_set(props, "NewProp", strdup("newValue"), NULL);
59 /* Print the properties of the workstation 1 */
60 xbt_dict_foreach(props, cursor, key, data) {
61 XBT_INFO("\tProperty: %s has value: %s", key, data);
64 /* Try to get a property that does not exist */
66 value = SD_workstation_get_property_value(w1, noexist);
68 XBT_INFO("\tProperty: %s is undefined", noexist);
70 XBT_INFO("\tProperty: %s has value: %s", noexist, value);
73 XBT_INFO("Property list for workstation %s", name2);
74 /* Get the property list of the workstation 2 */
75 props = SD_workstation_get_properties(w2);
78 /* Print the properties of the workstation 2 */
79 xbt_dict_foreach(props, cursor, key, data) {
80 XBT_INFO("\tProperty: %s on host: %s", key, data);
83 /* Modify an existing property test. First check it exists */
84 XBT_INFO("Modify an existing property");
86 value = SD_workstation_get_property_value(w2, exist);
88 XBT_INFO("\tProperty: %s is undefined", exist);
90 XBT_INFO("\tProperty: %s old value: %s", exist, value);
91 xbt_dict_set(props, exist, strdup("250"), NULL);
94 /* Test if we have changed the value */
95 value = SD_workstation_get_property_value(w2, exist);
97 XBT_INFO("\tProperty: %s is undefined", exist);
99 XBT_INFO("\tProperty: %s new value: %s", exist, value);
101 /* Test if properties are displayed by SD_workstation_dump */
102 SD_workstation_dump(w2);