1 /* Copyright (c) 2008-2010, 2012-2015. 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 "simgrid/simdag.h"
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd,
13 "SimDag test basic_link_test");
15 static int cmp_link(const void*a, const void*b) {
16 const char *nameA = SD_link_get_name(*(SD_link_t*)a);
17 const char *nameB = SD_link_get_name(*(SD_link_t*)b);
18 return strcmp( nameA, nameB );
21 int main(int argc, char **argv)
24 const char *user_data = "some user_data";
25 const SD_link_t *links;
27 /* initialization of SD */
30 /* creation of the environment */
31 SD_create_environment(argv[1]);
32 links = SD_link_get_list();
33 int count = SD_link_get_number();
34 XBT_INFO("Link count: %d", count);
35 qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
37 for(i=0; i<SD_link_get_number();i++){
38 XBT_INFO("%s: latency = %.5f, bandwidth = %f",
39 SD_link_get_name(links[i]),
40 SD_link_get_current_latency(links[i]),
41 SD_link_get_current_bandwidth(links[i]));
42 SD_link_set_data(links[i], (void*) user_data);
43 if(strcmp(user_data, (const char*)SD_link_get_data(links[i]))){
44 XBT_ERROR("User data was corrupted.");