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. */
8 #include "simgrid/simdag.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, sd, "SimDag test basic_link_test");
12 static int cmp_link(const void*a, const void*b) {
13 return strcmp(sg_link_name(*(SD_link_t*)a) , sg_link_name(*(SD_link_t*)b));
16 int main(int argc, char **argv)
18 const char *user_data = "some user_data";
20 /* initialization of SD */
23 /* creation of the environment */
24 SD_create_environment(argv[1]);
25 SD_link_t *links = sg_link_list();
26 int count = sg_link_count();
27 XBT_INFO("Link count: %d", count);
28 qsort((void *)links, count, sizeof(SD_link_t), cmp_link);
30 for (int i=0; i < count; i++){
31 XBT_INFO("%s: latency = %.5f, bandwidth = %f", sg_link_name(links[i]),
32 sg_link_latency(links[i]), sg_link_bandwidth(links[i]));
33 sg_link_data_set(links[i], (void*) user_data);
34 xbt_assert(!strcmp(user_data, (const char*)sg_link_data(links[i])),"User data was corrupted.");