Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
never ending cleanup of the simdag world
[simgrid.git] / teshsuite / simdag / platforms / basic_link_test.c
1 /* Copyright (c) 2008-2010, 2012-2015. 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 "simgrid/simdag.h"
9 #include "xbt/log.h"
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test");
12
13 static int cmp_link(const void*a, const void*b) {
14   return strcmp(sg_link_name(*(SD_link_t*)a)  , sg_link_name(*(SD_link_t*)b));
15 }
16
17 int main(int argc, char **argv)
18 {
19   const char *user_data = "some user_data";
20
21   /* initialization of SD */
22   SD_init(&argc, argv);
23
24   /* creation of the environment */
25   SD_create_environment(argv[1]);
26   const SD_link_t *links = sg_link_list();
27   int count = sg_link_count();
28   XBT_INFO("Link count: %d", count);
29   qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
30    
31   for (int i=0; i < count; i++){
32     XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]),
33              sg_link_latency(links[i]), sg_link_bandwidth(links[i]));
34     sg_link_data_set(links[i], (void*) user_data);
35     xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted.");
36   }
37
38   SD_exit();
39   return 0;
40 }