Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
spell check the comments
[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 #include "surf/surf_private.h"
11
12 int main(int argc, char **argv)
13 {
14   /* SD initialization */
15
16   SD_workstation_t w1, w2;
17   const SD_workstation_t *workstations;
18   const SD_link_t *route;
19   const char *name1;
20   const char *name2;
21   int route_size, i, j, k;
22   int list_size;
23
24 #ifdef _XBT_WIN32
25   setbuf(stderr, NULL);
26   setbuf(stdout, NULL);
27 #else
28   setvbuf(stdout, NULL, _IOLBF, 0);
29 #endif
30
31   SD_init(&argc, argv);
32
33   /* creation of the environment */
34   SD_create_environment(argv[1]);
35   printf("Workstation number: %d, link number: %d\n",
36          SD_workstation_get_number(), SD_link_get_number());
37
38   if (argc >= 3) {
39     if (!strcmp(argv[2], "ONE_LINK")) {
40       workstations = SD_workstation_get_list();
41       w1 = workstations[0];
42       w2 = workstations[1];
43       name1 = SD_workstation_get_name(w1);
44       name2 = SD_workstation_get_name(w2);
45
46       printf("Route between %s and %s\n", name1, name2);
47       route = SD_route_get_list(w1, w2);
48       route_size = SD_route_get_size(w1, w2);
49       printf("Route size %d\n", route_size);
50       for (i = 0; i < route_size; i++) {
51       printf("  Link %s: latency = %f, bandwidth = %f\n",
52            SD_link_get_name(route[i]),
53            SD_link_get_current_latency(route[i]),
54            SD_link_get_current_bandwidth(route[i]));
55       }
56       printf("Route latency = %f, route bandwidth = %f\n",
57          SD_route_get_current_latency(w1, w2),
58          SD_route_get_current_bandwidth(w1, w2));
59     }
60     if (!strcmp(argv[2], "FULL_LINK")) {
61       workstations = SD_workstation_get_list();
62       list_size = SD_workstation_get_number();
63       for (i = 0; i < list_size; i++) {
64       w1 = workstations[i];
65       name1 = SD_workstation_get_name(w1);
66       for (j = 0; j < list_size; j++) {
67         w2 = workstations[j];
68         name2 = SD_workstation_get_name(w2);
69         printf("Route between %s and %s\n", name1, name2);
70         route = SD_route_get_list(w1, w2);
71         route_size = SD_route_get_size(w1, w2);
72         printf("  Route size %d\n", route_size);
73         for (k = 0; k < route_size; k++) {
74         printf("  Link %s: latency = %f, bandwidth = %f\n",
75              SD_link_get_name(route[k]),
76              SD_link_get_current_latency(route[k]),
77              SD_link_get_current_bandwidth(route[k]));
78         }
79         printf("  Route latency = %f, route bandwidth = %f\n",
80            SD_route_get_current_latency(w1, w2),
81            SD_route_get_current_bandwidth(w1, w2));
82       }
83       }
84     }
85     if (!strcmp(argv[2], "PROP")) {
86       printf("SG_TEST_mem: %s\n",
87           SD_workstation_get_property_value(SD_workstation_get_by_name("host1"),
88           "SG_TEST_mem")
89           );
90       printf("Author: %s\n", SD_as_router_get_property_value("AS0", "author"));
91       printf("AS1: %s\n", SD_as_router_get_property_value("AS1", "name"));
92       printf("AS2: %s\n", SD_as_router_get_property_value("AS2", "name"));
93     }
94   }
95
96   SD_exit();
97   return 0;
98 }