1 /* Copyright (c) 2008-2022. 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. */
7 #include "simgrid/s4u.hpp"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(basic_link_test, s4u, "basic link test");
12 int main(int argc, char** argv)
14 std::string user_data = "some user_data";
16 /* initialization of SD */
17 simgrid::s4u::Engine e(&argc, argv);
19 /* creation of the environment */
20 e.load_platform(argv[1]);
22 std::vector<simgrid::s4u::Link*> links = e.get_all_links();
23 XBT_INFO("Link count: %zu", links.size());
25 std::sort(links.begin(), links.end(), [](const simgrid::s4u::Link* a, const simgrid::s4u::Link* b) {
26 return strcmp(sg_link_get_name(a), sg_link_get_name(b)) < 0;
29 for (const auto& l : links) {
30 XBT_INFO("%s: latency = %.5f, bandwidth = %f", l->get_cname(), l->get_latency(), l->get_bandwidth());
31 l->set_data(&user_data);
32 xbt_assert(user_data == *l->get_data<std::string>(), "User data was corrupted.");