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