Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5a484e341180b050c5699e9173b3bec730d722c4
[simgrid.git] / teshsuite / simdag / platforms / basic_link_test.c
1 /* Copyright (c) 2008-2010, 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "simdag/simdag.h"
10 #include "surf/surf_private.h"
11 #include "xbt/log.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd,
14                                 "SimDag test basic_link_test");
15
16 int main(int argc, char **argv)
17 {
18   int i;
19   const char *user_data = "some user_data";
20   const SD_link_t *links;
21
22   /* initialization of SD */
23   SD_init(&argc, argv);
24
25   /* creation of the environment */
26   SD_create_environment(argv[1]);
27   XBT_INFO("Link number: %d", SD_link_get_number());
28   links = SD_link_get_list();
29   for(i=0; i<SD_link_get_number();i++){
30     XBT_INFO("%s: latency = %.5f, bandwidth = %f",
31              SD_link_get_name(links[i]),
32              SD_link_get_current_latency(links[i]),
33              SD_link_get_current_bandwidth(links[i]));
34     SD_link_set_data(links[i], (void*) user_data);
35     if(strcmp(user_data, (const char*)SD_link_get_data(links[i]))){
36       XBT_ERROR("User data was corrupted.");
37     }
38   }
39
40   SD_exit();
41   return 0;
42 }