Logo AND Algorithmique Numérique Distribuée

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