Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill old cruft
[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 <stdlib.h>
9 #include "simgrid/simdag.h"
10
11 int main(int argc, char **argv)
12 {
13   /* SD initialization */
14
15   sg_host_t w1, w2;
16   sg_host_t *workstations;
17   SD_link_t *route;
18   const char *name1;
19   const char *name2;
20   int route_size, i, j, k;
21   int list_size;
22
23   SD_init(&argc, argv);
24
25   /* creation of the environment */
26   SD_create_environment(argv[1]);
27   printf("Workstation number: %zu, link number: %d\n",
28          sg_host_count(), sg_link_count());
29
30   workstations = sg_host_list();
31   if (argc >= 3) {
32     if (!strcmp(argv[2], "ONE_LINK")) {
33       w1 = workstations[0];
34       w2 = workstations[1];
35       name1 = sg_host_get_name(w1);
36       name2 = sg_host_get_name(w2);
37
38       printf("Route between %s and %s\n", name1, name2);
39       route = SD_route_get_list(w1, w2);
40       route_size = SD_route_get_size(w1, w2);
41       printf("Route size %d\n", route_size);
42       for (i = 0; i < route_size; i++) {
43       printf("  Link %s: latency = %f, bandwidth = %f\n",
44            sg_link_name(route[i]),
45            sg_link_latency(route[i]),
46            sg_link_bandwidth(route[i]));
47       }
48       printf("Route latency = %f, route bandwidth = %f\n",
49          SD_route_get_latency(w1, w2),
50          SD_route_get_bandwidth(w1, w2));
51       xbt_free(route);
52     }
53     if (!strcmp(argv[2], "FULL_LINK")) {
54       list_size = sg_host_count();
55       for (i = 0; i < list_size; i++) {
56       w1 = workstations[i];
57       name1 = sg_host_get_name(w1);
58       for (j = 0; j < list_size; j++) {
59         w2 = workstations[j];
60         name2 = sg_host_get_name(w2);
61         printf("Route between %s and %s\n", name1, name2);
62         route = SD_route_get_list(w1, w2);
63         route_size = SD_route_get_size(w1, w2);
64         printf("  Route size %d\n", route_size);
65         for (k = 0; k < route_size; k++) {
66         printf("  Link %s: latency = %f, bandwidth = %f\n",
67              sg_link_name(route[k]),
68              sg_link_latency(route[k]),
69              sg_link_bandwidth(route[k]));
70         }
71         printf("  Route latency = %f, route bandwidth = %f\n",
72            SD_route_get_latency(w1, w2),
73            SD_route_get_bandwidth(w1, w2));
74         xbt_free(route);
75       }
76       }
77     }
78     if (!strcmp(argv[2], "PROP")) {
79       printf("SG_TEST_mem: %s\n",
80           sg_host_get_property_value(sg_host_by_name("host1"),
81           "SG_TEST_mem"));
82     }
83   }
84   xbt_free(workstations);
85
86   SD_exit();
87   return 0;
88 }