~ubuntu-branches/ubuntu/raring/simgrid/raring

« back to all changes in this revision

Viewing changes to examples/msg/properties/msg_prop.c

  • Committer: Package Import Robot
  • Author(s): Martin Quinson
  • Date: 2013-01-31 00:24:51 UTC
  • mfrom: (10.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20130131002451-krejhf7w7h24lpsc
Tags: 3.9~rc1-1
* New upstream release: the "Grasgory" release. Major changes:
  - Gras was completely removed from this version.
  - Documentation reorganization to ease browsing it.
  - New default value for the TCP_gamma parameter: 4MiB

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
int bob(int argc, char *argv[]);
33
33
int carole(int argc, char *argv[]);
34
34
int forwarder(int argc, char *argv[]);
35
 
MSG_error_t test_all(const char *platform_file,
 
35
msg_error_t test_all(const char *platform_file,
36
36
                     const char *application_file);
37
37
 
38
38
static void test_host(const char*hostname) 
39
39
{
40
 
  m_host_t thehost = MSG_get_host_by_name(hostname);
 
40
  msg_host_t thehost = MSG_get_host_by_name(hostname);
41
41
  xbt_dict_t props = MSG_host_get_properties(thehost);
42
42
  xbt_dict_cursor_t cursor = NULL;
43
43
  char *key, *data;
44
44
  const char *noexist = "Unknown";
45
45
  const char *value;
46
 
  char exist[] = "SG_TEST_Hdd";
 
46
  char exist[] = "Hdd";
47
47
 
48
48
  XBT_INFO("== Print the properties of the host");
49
49
  xbt_dict_foreach(props, cursor, key, data)
63
63
  XBT_INFO("   Property: %s old value: %s", exist, value);
64
64
 
65
65
  XBT_INFO("== Trying to modify a host property");
66
 
  xbt_dict_set(props, exist, xbt_strdup("250"), NULL);
 
66
  MSG_host_set_property_value(thehost, exist, xbt_strdup("250"), NULL);
67
67
 
68
68
  /* Test if we have changed the value */
69
69
  value = MSG_host_get_property_value(thehost, exist);
74
74
  XBT_INFO("   Property: %s old value: %s", exist, value);
75
75
   
76
76
  /* Restore the value for the next test */
77
 
  xbt_dict_set(props, exist, xbt_strdup("180"), NULL);
 
77
  MSG_host_set_property_value(thehost, exist, xbt_strdup("180"), NULL);
78
78
}
79
79
 
80
80
int alice(int argc, char *argv[]) { /* Dump what we have on the current host */
109
109
}
110
110
 
111
111
/** Test function */
112
 
MSG_error_t test_all(const char *platform_file,
 
112
msg_error_t test_all(const char *platform_file,
113
113
                     const char *application_file)
114
114
{
 
115
  int host_number;
 
116
  unsigned int i;
 
117
  xbt_dynar_t hosts;
 
118
  msg_host_t host;
115
119
  MSG_function_register("alice", alice);
116
120
  MSG_function_register("bob", bob);
117
121
  MSG_function_register("carole", carole);
118
122
 
119
123
  MSG_create_environment(platform_file);
 
124
 
 
125
  host_number = MSG_get_host_number();
 
126
  XBT_INFO("There are %d hosts in the environment", host_number);
 
127
 
 
128
  hosts = MSG_hosts_as_dynar();
 
129
 
 
130
  xbt_dynar_foreach(hosts, i, host){
 
131
    XBT_INFO("Host '%s' runs at %.0f flops/s",MSG_host_get_name(host),
 
132
       MSG_get_host_speed(host));
 
133
  }
 
134
 
120
135
  MSG_launch_application(application_file);
121
136
 
122
137
  return MSG_main();
126
141
/** Main function */
127
142
int main(int argc, char *argv[])
128
143
{
129
 
  MSG_error_t res = MSG_OK;
 
144
  msg_error_t res = MSG_OK;
130
145
 
131
 
  MSG_global_init(&argc, argv);
 
146
  MSG_init(&argc, argv);
132
147
  if (argc < 3) {
133
148
    printf("Usage: %s platform_file deployment_file\n", argv[0]);
134
149
    printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]);
135
150
    exit(1);
136
151
  }
137
152
  res = test_all(argv[1], argv[2]);
138
 
  MSG_clean();
139
153
 
140
154
  if (res == MSG_OK)
141
155
    return 0;