Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix distcheck
[simgrid.git] / teshsuite / simdag / platforms / basic_parsing_test.c
1 /* Copyright (c) 2008-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 "simgrid/simdag.h"
9
10 int main(int argc, char **argv)
11 {
12   SD_init(&argc, argv);
13
14   /* creation of the environment */
15   SD_create_environment(argv[1]);
16   printf("Workstation number: %zu, link number: %d\n", sg_host_count(), sg_link_count());
17
18   sg_host_t *hosts = sg_host_list();
19   if (argc >= 3) {
20     if (!strcmp(argv[2], "ONE_LINK")) {
21       sg_host_t h1 = hosts[0];
22       sg_host_t h2 = hosts[1];
23       const char *name1 = sg_host_get_name(h1);
24       const char *name2 = sg_host_get_name(h2);
25
26       printf("Route between %s and %s\n", name1, name2);
27       SD_link_t *route = SD_route_get_list(h1, h2);
28       int route_size = SD_route_get_size(h1, h2);
29       printf("Route size %d\n", route_size);
30       for (int i = 0; i < route_size; i++)
31         printf("  Link %s: latency = %f, bandwidth = %f\n", sg_link_name(route[i]),
32                sg_link_latency(route[i]), sg_link_bandwidth(route[i]));
33       printf("Route latency = %f, route bandwidth = %f\n",
34              SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
35       xbt_free(route);
36     }
37     if (!strcmp(argv[2], "FULL_LINK")) {
38       int list_size = sg_host_count();
39       for (int i = 0; i < list_size; i++) {
40         sg_host_t h1 = hosts[i];
41         const char *name1 = sg_host_get_name(h1);
42         for (int j = 0; j < list_size; j++) {
43           sg_host_t h2 = hosts[j];
44           const char *name2 = sg_host_get_name(h2);
45           printf("Route between %s and %s\n", name1, name2);
46           SD_link_t *route = SD_route_get_list(h1, h2);
47           int route_size = SD_route_get_size(h1, h2);
48           printf("  Route size %d\n", route_size);
49           for (int k = 0; k < route_size; k++) {
50             printf("  Link %s: latency = %f, bandwidth = %f\n",
51                 sg_link_name(route[k]), sg_link_latency(route[k]), sg_link_bandwidth(route[k]));
52           }
53           printf("  Route latency = %f, route bandwidth = %f\n",
54                  SD_route_get_latency(h1, h2), SD_route_get_bandwidth(h1, h2));
55           xbt_free(route);
56         }
57       }
58     }
59     if (!strcmp(argv[2], "PROP"))
60       printf("SG_TEST_mem: %s\n", sg_host_get_property_value(sg_host_by_name("host1"), "SG_TEST_mem"));
61   }
62   xbt_free(hosts);
63
64   SD_exit();
65   return 0;
66 }